@@ -18,41 +18,45 @@ C<Instant> to a C<Duration> returns another Instant. Subtracting two C<Instant>s
18
18
will yield a C < Duration > . Adding two C < Instant > s is explicitly disallowed. All
19
19
other operations with Instants are undefined.
20
20
21
- = head1 Methods
22
-
23
- = head2 method from-posix
21
+ = head1 Future Leap Seconds
24
22
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:
39
29
40
30
$ perl6-2016.06 -e 'say Instant.from-posix: 1485726595'
41
31
Instant:1485726631
42
32
43
33
$ perl6-2016.07 -e 'say Instant.from-posix: 1485726595'
44
34
Instant:1485726632
45
35
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:
49
40
50
41
$ perl6-2016.06 -e 'say ($*VM.version before 2016.07 ?? 1 !! 0) + Instant.from-posix: 1485726595'
51
42
Instant:1485726632
52
43
53
44
$ perl6-2016.07 -e 'say ($*VM.version before 2016.07 ?? 1 !! 0) + Instant.from-posix: 1485726595'
54
45
Instant:1485726632
55
46
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
+
56
60
= head2 method to-posix
57
61
58
62
method to-posix()
0 commit comments