vapor / template-kit

📄 Easy-to-use foundation for building powerful templating languages in Swift.
MIT License
46 stars 17 forks source link

DateFormat tag and TemplateDataRepresentable use different date encoding #20

Closed grundoon closed 6 years ago

grundoon commented 6 years ago

Just noticed that the DateFormat tag uses Date(timeIntervalSinceReferenceDate:), whereas the TemplateDataRepresentable extension Date.convertToTemplateData is using timeIntervalSince1970 – these should probably be synched up, no?

Note: The recently merged https://github.com/vapor/template-kit/pull/18 uses timeIntervalSince1970 as well, since it is just reversing the TemplateData conversion.

tanner0101 commented 6 years ago

Yeah, you are right. There was another bug in the template data encoder that was not seeing TemplateDataRepresentable correctly. Fixing that issue lead to dates being properly serialized as timeIntervalSince1970.

I've changed DateFormat to use unix epoch and added a test. Thanks!