Skip to content

Commit 9498349

Browse files
authored
Document future leap second behaviour
Related to https://rt.perl.org/Ticket/Display.html?id=126119
1 parent 9fbfc11 commit 9498349

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

doc/Type/Instant.pod6

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,28 @@ the first of the two possible seconds in the case of a leap second.
3131
say DateTime.new(Instant.from-posix(915148800, True)); # 1998-12-31T23:59:60Z
3232
say DateTime.new(Instant.from-posix(915148800)); # 1999-01-01T00:00:00Z
3333
34+
B<Note:> the method does not attempt to make any guesses about possible positions
35+
of leap seconds in the future and only uses the already-known leap seconds.
36+
This means you can get different results, depending on the compiler version you're
37+
using. For example, the December 31, 2016 leap second was announced in July and
38+
shipped with Rakudo 2016.07, so 2016.06 and earlier releases won't know about it:
39+
40+
$ perl6-2016.06 -e 'say Instant.from-posix: 1485726595'
41+
Instant:1485726631
42+
43+
$ perl6-2016.07 -e 'say Instant.from-posix: 1485726595'
44+
Instant:1485726632
45+
46+
Since a Rakudo compiler always returns 0 for future leap seconds it doesn't know
47+
about, you can patch your old code when new leap seconds are announced, so it
48+
will give correct results, regardless of what version of the compiler it's run on:
49+
50+
$ perl6-2016.06 -e 'say ($*VM.version before 2016.07 ?? 1 !! 0) + Instant.from-posix: 1485726595'
51+
Instant:1485726632
52+
53+
$ perl6-2016.07 -e 'say ($*VM.version before 2016.07 ?? 1 !! 0) + Instant.from-posix: 1485726595'
54+
Instant:1485726632
55+
3456
=head2 method to-posix
3557
3658
method to-posix()

0 commit comments

Comments
 (0)