Hi, all.

During a discussion in CocoaHeads Brazil, one developer came with a very odd 
situation involving Foundation’s DateFormatter class. Here is the code:

import Foundation

let fmt = DateFormatter()
fmt.dateFormat = "yyyy-MM-dd"
let aDate = fmt.date(from: "2017-10-15”)

The variable aDate is becoming nil. In order to reproduce it, you will need to 
change the time zone to Americas/Sao_Paulo in your system. On other time zones, 
it works perfectly.

There is another important fact: 15 of October is when day light savings is 
effective in Brazil. 

Debugging this, I have found that setting the calendar property, it works 
perfectly, which means that it possibly be a bug on Core Foundation (I found 
that DateFormatter, in fact, calls Core Foundation functions under the hood).

I’d like to know if you guys can reproduce it on other time zones that have a 
day light saving, for the day that it become effective.

Cheers!

Ronaldo Faria Lima

Nineteen
rona...@nineteen.com.br
+55 16 98136 5287








_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users
  • [swift-users] DateFormatter ... Ronaldo Faria Lima via swift-users

Reply via email to