Posted about 9 years ago. Visible to the public. Repeats. Linked content.

Respect time zones: Use Time.current and Time.zone.parse

Reading the current time

Don't use Time.now as it's broken when using time zones. \
Instead, use Time.current, DateTime.current or Date.current (the latter actually not being different, but just use it for good measure).

Parsing strings

Don't use Time.parse as it only gives you a Time object.
Use Time.zone.parse instead for a TimeWithZone.

Owner of this card:

Avatar
Arne Hartherz
Last edit:
over 3 years ago
Posted by Arne Hartherz to HouseTrip Deck
This website uses short-lived cookies to improve usability.
Accept or learn more