News for hackers. Stuff that matters.

Ask HN: What is the best Date and Time library (in any language)?

Date and time and time zones are notoriously hard to handle correctly. What libraries handle time the best? Which ones make it the most difficult to shoot yourself in the foot? Which language has the best standard library date/time module?

Various dimensions for comparison include: - handling of timezones - handling of durations - handling of other date/time arithmetic - formatting and parsing - explicitness for handling time with timezones vs. UTC

( 3 comments | 5 points | on HN )
Re:Ask HN: What is the best Date and Time library (in any la... by dmt314159 on Saturday March 23, 2019 @08:22PM (#19473149)
perl5's DateTime "is a class for the representation of date/time combinations"

Apart from the modules included in the DateTimeDistribution, there are many others as returned by https://metacpan.org/search?q=DateTime

My favorite use DateTime::Format::Baby;

my $Baby = DateTime::Format::Baby->new('en'); my $dt = $Baby->parse_datetime('The big hand is on the twelve and the little hand is on the six.');

Re:Ask HN: What is the best Date and Time library (in any la... by smt88 on Friday March 22, 2019 @07:59PM (#19468065)
NodaTime is excellent, especially the way it differentiates between a calendar date and a point in time.
Re:Ask HN: What is the best Date and Time library (in any la... by quickthrower2 on Saturday March 23, 2019 @05:27AM (#19469753)
.net DateTime class is reasonable out of the box.