@@ -57,12 +57,14 @@ multi method new(Instant:D $i, :$timezone=0, :&formatter)
5757multi method new(Numeric:D $posix, :$timezone=0, :&formatter)
5858multi method new(Str:D $format, :$timezone=0, :&formatter)
5959
60- Creates a new C<DateTime> object. One option for creating a new DateTime object
60+ Creates a new C<DateTime> object. One option for creating a new C< DateTime> object
6161is from the components (year, month, day, hour, ...) separately. Another is to
6262pass a L<C<Date>|/type/Date> object for the date component, and specify the time
6363component-wise. Yet another is to obtain the time from an
6464L<C<Instant>|/type/Instant>, and only supply the time zone and formatter. Or
65- instead of an Instant you can supply a L<C<Numeric>|/type/Numeric> as a UNIX timestamp.
65+ instead of an L<C<Instant>|/type/Instant> you can supply a L<C<Numeric>|/type/Numeric> as a Unix timestamp
66+ (but note that this last method provides no way to disambiguate leap seconds,
67+ unlike using L<C<Instant>|/type/Instant>).
6668
6769You can also supply a L<C<Str>|/type/Str> formatted in ISO 8601 timestamp
6870notation or as a full L<RFC 3339|https://tools.ietf.org/html/rfc3339>
@@ -263,6 +265,11 @@ Returns the instant's time as a fraction of a 24-hour day.
263265Notice the C<day-fraction> value is the same as the fractional part of
264266the C<modified-julian-date> for the same instant.
265267
268+ Also note that leap seconds may cause some variations from expected values:
269+
270+ for 30, 31 { say DateTime.new(2016,12,$_,12,0,0).day-fraction }
271+ # OUTPUT: «0.50.499994»
272+
266273Available as of the 2021.04 Rakudo compiler release.
267274
268275=head2 method julian-date
@@ -294,7 +301,9 @@ Returns the L<Modified Julian Date|https://en.wikipedia.org/wiki/Julian_day> (MJ
294301
295302 say DateTime.new('2021-12-24T12:23:00.43Z').modified-julian-date; # OUTPUT: «59572.5159772»
296303
297- Notice the fractional part of the C<modified-julian-date> is same value as the C<day-fraction> for the same instant.
304+ Notice the fractional part of the C<modified-julian-date> is same value as the
305+ L<C<day-fraction>|/type/DateTime#method_day-fraction> for the same instant, and
306+ is similarly affected by leap seconds.
298307Likewise, the integral part of the I<MJD> is the same value as the C<daycount> for the same instant since they
299308reference the same epoch (November 17, 1858).
300309The MJD is obtained by subtracting the constant C<2_400_000.5> from the I<Julian Date> and is used to simplify
@@ -310,14 +319,19 @@ Available as of the 2021.04 Rakudo compiler release.
310319
311320 method posix(Bool:D: $ignore-timezone = False --> Int:D)
312321
313- Returns the date and time as a POSIX/UNIX timestamp (integral seconds since the POSIX epoch,
322+ Returns the date and time as a POSIX/Unix timestamp (non-leap seconds since the POSIX epoch,
3143231970-01-01T00:00:00Z).
315324
316325If C<$ignore-timezone> is C<True>, the C<DateTime> object will be treated as if
317326the time zone offset is zero.
318327
319328 method posix(Bool:D: $ignore-timezone = False, :$real --> Num:D)
320329
330+ Note that this will collapse both a leap second and the second immediately
331+ following it into the same timestamp, because POSIX time ignores leap seconds.
332+ If you need better than this, see L<C<Instant>|/type/Instant> for the relevant
333+ methods.
334+
321335As of release 2022.06 of the Rakudo compiler, it is also possible to specify a
322336C<:real> named argument. If specified with a true value, a L<C<Num>|/type/Num> will be
323337returned, allowing for sub-second accuracy of the number of seconds since the
0 commit comments