のいくつかのために壊れているこれは、私が何をすべきかであるとき、ピッカーの変更:DateFormatter.localizedStringは日付
extension Date {
var fromCurrentToUTC: Date {
return addingTimeInterval(-TimeInterval(TimeZone.current.secondsFromGMT()))
}
}
var title = "--"
if let date = datePickerView.date?.fromCurrentToUTC {
title = DateFormatter.localizedString(from: date, dateStyle: .medium, timeStyle: .none)
}
print("-----")
print(datePickerView.date!)
print(title)
print(TimeZone.current)
print(datePickerView.date!.timeIntervalSince1970)
dateTimeSegmentControl.setTitle(title, forSegmentAt: 0)
そして、これはそれが日付のためにどのように見えるかです:
とする。 11月6日以前の日付はすべて正常で、11月6日以降はすべてがオフです。どうして?
更新:
重要な日付は、私が使用して、すべての時間帯の異なるされていること。たとえば:
ワルシャワ(0200)日は10月30日 あるシカゴ(-0500)は、日付が11月6日
注文したプリントです:あなたの関数で
----- 2017-11-04 00:00:00 +0000 4 Nov 2017 America/New_York (current) 1509753600.0 ----- 2017-11-05 00:00:00 +0000 5 Nov 2017 America/New_York (current) 1509840000.0 ----- 2017-11-06 00:00:00 +0000 5 Nov 2017 America/New_York (current) 1509926400.0 ----- 2017-11-07 00:00:00 +0000 6 Nov 2017 America/New_York (current) 1510012800.0
ほとんどおそらくワルシャワで2017年11月5日にある夏時間(の終わりに2017年10月29日シカゴで)。 –
どうすればよいですか?)これを回避するにはどうしたらいいですか? –
フィンランド(10月29日)のためにうまくいくようです - DateFormatter.localizedStringで間違った日付が表示されない –