-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Labels
Description
| Previous ID | SR-2846 |
| Radar | None |
| Original Reporter | UberJason (JIRA User) |
| Type | Bug |
| Status | Closed |
| Resolution | Done |
Environment
This code functions on OS X 10.11 but not in an Ubuntu 14.04 Docker image.
Here's the swift -version output on OS X 10.11:
Apple Swift version 3.0 (swiftlang-800.0.46.2 clang-800.0.38)
Target: x86_64-apple-macosx10.9And the swift -version output on the Ubuntu 14.04 Docker image:
Swift version 3.0 (swift-3.0-RELEASE)
Target: x86_64-unknown-linux-gnuAdditional Detail from JIRA
| Votes | 0 |
| Component/s | Foundation |
| Labels | Bug, Linux |
| Assignee | None |
| Priority | Medium |
md5: a9665d5c4946832d28b144569d47aae4
Issue Description:
The below snippet of code works on OS X 10.11 El Capitan but not on an Ubuntu 14.04 Docker image with Swift 3.0 RELEASE installed or the October 2 snapshot. Tested in REPL as well as, originally, in a Vapor web application, where I was doing some Date manipulations.
import Foundation
let today = Date()
let diffComponents = DateComponents(day: -1)
let newDate = Calendar.current.date(byAdding: diffComponents, to: today) //returns nilA few notes:
-
today is a valid Date object
-
Calendar.current is a valid Calendar object
-
I also tried manually checking that the date(from: DateComponents) function works, and it does:
todayComponents = DateComponents(year: 2016, month: 10, day: 4) Calendar.current.date(from: todayComponents) // returns valid Date on both platforms