Skip to content

Instantly share code, notes, and snippets.

@dogbert17
Last active May 8, 2016 12:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dogbert17/b5625897cf557437ed5b0e40b96c12de to your computer and use it in GitHub Desktop.
Save dogbert17/b5625897cf557437ed5b0e40b96c12de to your computer and use it in GitHub Desktop.
Trying to write some docs for Instant.from-posix and Instant.to-posix
=head1 Methods
=head2 method from-posix
method from-posix($posix, Bool $prefer-leap-second = False)
Converts the POSIX timestamp C<$posix> to an Instant.
If C<$prefer-leap-second> is C<True>, the return value will be
the first of the two possible seconds in the case of a leap second.
say DateTime.new(Instant.from-posix(915148800, True)); # 1998-12-31T23:59:60Z
say DateTime.new(Instant.from-posix(915148800)); # 1999-01-01T00:00:00Z
=head2 method to-posix
method to-posix()
Converts the invocant to a POSIX timestamp and returns a two
element list containing the POSIX timestamp and a C<Bool>.
It is the inverse of from-posix, except that the second return
value is C<True> if *and only if* this Instant is in a leap
second.
say DateTime.new("1999-01-01T00:00:00Z").Instant.to-posix # (915148800 False)
say DateTime.new('1998-12-31T23:59:60Z').Instant.to-posix; # (915148800 True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment