DEV Community

Discussion on: Top 7 Date methods you should know (Dart)

Collapse
ben profile image
Ben Halpern

This is a pretty solid representing of Dart. I feel like you can know a lot from how a language treats dates.

Collapse
rhymes profile image
rhymes • Edited on

Pleased to see that Dart is quite sane in its API and dates/times carry around the time zone.

I still get frustrated because after many years I still have to deal with date times without a timezone in Python. From the standard library:

>>> import datetime
>>> datetime.datetime.now()
datetime.datetime(2018, 9, 15, 1, 51, 58, 769069)
>>> datetime.datetime.utcnow()
datetime.datetime(2018, 9, 14, 23, 52, 4, 568886)
>>> datetime.datetime.now().isoformat()
'2018-09-15T01:52:14.024139'
>>> datetime.datetime.utcnow().isoformat()
'2018-09-14T23:52:23.090149'

Neither the local time, now(), nor the UTC time carry the time zone so if you pass that around you're bound to mess it up, they call those "naive datetimes" vs "time zone aware datetimes" but I call them "useless datetimes" :D

No wonder Python has so many datetime libraries (each word links to a different library :D)