Hacker News new | ask | show | jobs
by jjolla888 3504 days ago
> #Does what it says on the tin > say "Yippee" if $date.later(:5years).is-leap-year;

Is that a Georgian or Benghali or Indian or Buddist Era Thai leap year?

Actually are we talking the Georgian calendar - or the Julian, Revised Julian, Coptic, Ethiopian, Chinese, Hebrew, Islamic, Hindu, Bahai, or Solar Hejri calendar ?

2 comments

I have to admit the documentation for perl6 is absolutely excellent as the very first English prose line on the very first google result answers your very reasonable first question about a date class.

https://docs.perl6.org/type/Date

"A Date is an immutable object identifying a day in the Gregorian calendar."

I like a language that's not surprising, with easy to find answers. My experience with Perl over the decades is everything about it meets expectations to a spooky extent, which is also nice. The surprise factor for Perl is very low.

It seems to define excellence in programming language documentation. Is there anything better out there?

From https://docs.perl6.org/type/Date:

"A Date is an immutable object identifying a day in the Gregorian calendar."

(It's proleptic.)

The days used in DateTime, which is compatible with the Date class, also identify days in the Gregorian calendar.

(DateTime adopts RFC 3339[1].)

The `is-leap-year` methods for both classes refer to the Gregorian calendar year.

For a civil calendar independent date, use the `daycount` method to return a Modified Julian Day[2].

The `Dateish` role[3] abstracts from any particular civil calendar.

I'm not aware of any routines, built in or in existing Perl 6 modules, for conversion to other calendars.

[1] https://www.ietf.org/rfc/rfc3339.txt

[2] http://tycho.usno.navy.mil/mjd.html

[3] https://docs.perl6.org/type/Dateish