Re: DateTime: (now.Int) always 37 seconds off from (now)
[email protected] (Andy Bach) Fri, 29 Aug 2025 09:52:15 -0500
| Newsgroups | perl.perl6.users |
|---|---|
| Message-ID | <CACV6rWJ-OBbyXqMySbpzjLoESLqzXb7N-itBbqr1FV0JNVGaRw@mail.gmail.com> |
raku -e 'my $inst = now; put $inst, "\t", $inst.Int; put
DateTime.new($inst).local, "\t", DateTime.new($inst.Int).local,"\t",
DateTime.new($inst).local.truncated-to("second")'
Instant:1756479067.146121 1756479067
2025-08-29T09:50:30.146121-05:00 2025-08-29T09:51:07-05:00
2025-08-29T09:50:30-05:00
same 37 second difference
On Fri, Aug 29, 2025 at 9:23 AM Bruce Gray <[email protected]>
wrote:
>
>
> On Aug 29, 2025, at 09:14, Mark Devine <[email protected]> wrote:
>
> Rakoons,
>
> --snip--
>
> In the end, I’m looking for elegant mechanics to get DateTime objects from
> multiple sources (including now), perform calculations, etc., then produce
> this format using .Str:
> YYYY-MM-DDT*HH:MM:SS*-04:00
> not this format:
> YYYY-MM-DDT*HH:MM:SS*.806520-04:00
>
>
>
> Hi Mark,
>
> This should work:
> raku -e 'say DateTime.now.truncated-to("second");'
> 2025-08-29T09:18:57-05:00
>
> Docs:
> https://docs.raku.org/type/DateTime#method_truncated-to
>
> --
> Hope this helps,
> Bruce Gray (Util of PerlMonks)
>
--
a
Andy Bach,
[email protected]
608 658-1890 cell
608 261-5738 wk