Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add description of three new DateTime methods #3860

Merged
merged 7 commits into from Jun 14, 2021
Merged
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
46 changes: 46 additions & 0 deletions doc/Type/DateTime.pod6
Expand Up @@ -252,6 +252,52 @@ Returns an L<Instant|/type/Instant> object based on the invocant.

say DateTime.new('2015-12-24T12:23:00+0200').Instant; # OUTPUT: «Instant:1450952616␤»

=head2 method day-fraction

Defined as:

method day-fraction(DateTime:D: --> Real:D)

Returns the instant's time as a fraction of a 24-hour day.
tbrowder marked this conversation as resolved.
Show resolved Hide resolved

say DateTime.new('2021-12-24T12:23:00.43Z').day-fraction; # OUTPUT: «0.5159772␤»

Notice the C<day-fraction> value is the same as the fractional part of
the C<modified-julian-date> for the same instant.

=head2 method julian-date

Defined as:

method julian-date(DateTime:D: --> Real:D)

Returns the L<Julian date|https://en.wikipedia.org/wiki/Julian_day> (JD) for the UTC date and time.

say DateTime.new('2021-12-24T12:23:00.43Z').julian-date; # OUTPUT: «2459573.0159772␤»

The C<julian-date> starts at zero at the epoch of noon UTC on
I<Monday, January 1, 4713 BC> (-4713-01-01T12:00:00Z), on the Gregorian calendar (the calendar
in use in much of the world and in international commerce and travel)
and is used in astronomy to define times of celestial objects transiting the
Earth's Prime Meridian. For an instant, it is the sum of the number of whole days and
the fraction of a day from that epoch to that instant.

=head2 method modified-julian-date

Defined as:

method modified-julian-date(DateTime:D: --> Real:D)

Returns the L<Modified Julian Date|https://en.wikipedia.org/wiki/Julian_day> (MJD) for the UTC date and time.

say DateTime.new('2021-12-24T12:23:00.43Z').modified-julian-date; # OUTPUT: «59572.5159772␤»

Notice the fractional part of the C<modified-julian-date> is same value as the C<day-fraction> for the same instant.
tbrowder marked this conversation as resolved.
Show resolved Hide resolved
Likewise, the integral part of the I<MJD> is the same value as the C<daycount> for the same instant since they
reference the same epoch (Nov. 17, 1858).
The MJD is obtained by subtracting the constant C<2_400_000.5> from the I<Julian Date> and is used to simplify
transformations between civil and astronmical time systems.

=head2 method posix

Defined as:
Expand Down