Skip to content

Commit

Permalink
Document DateTime.posix(:real)
Browse files Browse the repository at this point in the history
  • Loading branch information
lizmat committed Mar 7, 2023
1 parent cae02e1 commit 1d11030
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion doc/Type/DateTime.rakudoc
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,17 @@ Returns the date and time as a POSIX/UNIX timestamp (integral seconds since the
If C<$ignore-timezone> is C<True>, the C<DateTime> object will be treated as if
the time zone offset is zero.

method posix(Bool:D: $ignore-timezone = False, :real --> Num:D)

As of release 2022.06 of the Rakudo compiler, it is also possible to specify a
C<:real> named argument. If specified with a true value, a C<Num> will be
returned, allowing for sub-second accuracy of the number of seconds since the
POSIX epoch.

=for code
say DateTime.new('2015-12-24T12:23:00Z').posix; # OUTPUT: «1450959780␤»
say DateTime.new('2015-12-24T12:23:00Z').posix; # OUTPUT: «1450959780␤»
say DateTime.new('2022-06-21T12:23:00.5Z').posix; # OUTPUT: «1655814180␤»
say DateTime.new('2022-06-21T12:23:00.5Z').posix(:real); # OUTPUT: «1655814180.5␤»

=head2 method truncated-to

Expand Down

0 comments on commit 1d11030

Please sign in to comment.