Skip to content

Commit d0c34fa

Browse files
committed
Move prose on future leap seconds to its own section
There are many methods that have this caveat, not just .from-posix
1 parent 9498349 commit d0c34fa

File tree

1 file changed

+24
-20
lines changed

1 file changed

+24
-20
lines changed

doc/Type/Instant.pod6

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,41 +18,45 @@ C<Instant> to a C<Duration> returns another Instant. Subtracting two C<Instant>s
1818
will yield a C<Duration>. Adding two C<Instant>s is explicitly disallowed. All
1919
other operations with Instants are undefined.
2020
21-
=head1 Methods
22-
23-
=head2 method from-posix
21+
=head1 Future Leap Seconds
2422
25-
method from-posix($posix, Bool $prefer-leap-second = False)
26-
27-
Converts the POSIX timestamp C<$posix> to an Instant.
28-
If C<$prefer-leap-second> is C<True>, the return value will be
29-
the first of the two possible seconds in the case of a leap second.
30-
31-
say DateTime.new(Instant.from-posix(915148800, True)); # 1998-12-31T23:59:60Z
32-
say DateTime.new(Instant.from-posix(915148800)); # 1999-01-01T00:00:00Z
33-
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:
23+
Perl 6's methods that involve knowledge of leap seconds do not
24+
make any guesses for leap seconds in the future and only use the already-known
25+
leap seconds. This means you can get different results, depending on the
26+
compiler version you're using. For example, the December 31, 2016 leap second
27+
was announced in July and shipped with Rakudo 2016.07, so 2016.06 and earlier
28+
releases won't know about it:
3929
4030
$ perl6-2016.06 -e 'say Instant.from-posix: 1485726595'
4131
Instant:1485726631
4232
4333
$ perl6-2016.07 -e 'say Instant.from-posix: 1485726595'
4434
Instant:1485726632
4535
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:
36+
Since a Rakudo compiler always returns 0 for future leap seconds it doesn't
37+
know about, you can patch your old code when new leap seconds are announced,
38+
so it will give correct results, regardless of what version of the compiler
39+
it runs on:
4940
5041
$ perl6-2016.06 -e 'say ($*VM.version before 2016.07 ?? 1 !! 0) + Instant.from-posix: 1485726595'
5142
Instant:1485726632
5243
5344
$ perl6-2016.07 -e 'say ($*VM.version before 2016.07 ?? 1 !! 0) + Instant.from-posix: 1485726595'
5445
Instant:1485726632
5546
47+
=head1 Methods
48+
49+
=head2 method from-posix
50+
51+
method from-posix($posix, Bool $prefer-leap-second = False)
52+
53+
Converts the POSIX timestamp C<$posix> to an Instant.
54+
If C<$prefer-leap-second> is C<True>, the return value will be
55+
the first of the two possible seconds in the case of a leap second.
56+
57+
say DateTime.new(Instant.from-posix(915148800, True)); # 1998-12-31T23:59:60Z
58+
say DateTime.new(Instant.from-posix(915148800)); # 1999-01-01T00:00:00Z
59+
5660
=head2 method to-posix
5761
5862
method to-posix()

0 commit comments

Comments
 (0)