Re: DateTime: (now.Int) always 37 seconds off from (now)
An unfortunately named function, since `truncate` is a common term and
`truncate-to` give no hint that `DateTime` is involved.
A much better name would be `trunc-date`, possibly with a `:to` named-parameter.
Thoughts?
Cheers,
Bill.
PS. Perl reference: https://perldoc.perl.org/functions/truncate
> On Aug 29, 2025, at 08:05, Mark Devine wrote:
>
> Bruce,
>
> Asked for elegant. Received elegant.
>
> raku -e 'my $inst = now; put DateTime.new($inst).local, "\t",
> DateTime.new($inst).truncated-to("second").local;'
> 2025-08-29T10:57:31.276115-04:002025-08-29T10:57:31-04:00
>
> .truncated-to didn’t jump out at me when scanning class DateTime | Raku
> Documentation
> <https://urldefense.proofpoint.com/v2/url?u=https-3A__docs.raku.org_type_DateTime&d=DwMGaQ&c=009klHSCxuh5AI1vNQzSO0KGjl4nbi2Q0M1QLJX9BeE&r=H_4IX2PNs5J8Am4L9k8XPDKLi8_PeuhJoKcQtnXHZ4c&m=A83LDo7Xg3i5Wz0BEZ59mdh4AUvU95kuqekP5JO4JizPYEdOlOiHkpw950dx6yPz&s=N6rINXA5jyzFrI9qNysvvdPsmyFWe7BzTONJ8pIv-CE&e=>,
> but I’ve got it now.
>
> Thanks!
>
> Mark
>
>
> From: Bruce Gray
> Sent: Friday, August 29, 2025 10:24 AM
> To: Mark Devine
> Cc: perl6-users
> Subject: Re: DateTime: (now.Int) always 37 seconds off from (now)
>
>
>
>
> On Aug 29, 2025, at 09:14, Mark Devine <mailto:[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:
> -MM-DDTHH:MM:SS-04:00
> not this format:
> -MM-DDTHH: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
> <https://urldefense.proofpoint.com/v2/url?u=https-3A__docs.raku.org_type_DateTime-23method-5Ftruncated-2Dto&d=DwMFaQ&c=euGZstcaTDllvimEN8b7jXrwqOf-v5A_CdpgnVfiiMM&r=thT0VsM9yJlPPLROt23gXb6x82v5JicoCnxKT8v5YUo&m=IUEIKGuypZHWmV48ZWHC1oCTBivDAGisVF0N2rNmN81DXrTspMZbZOC9rMYYDp48&s=_EwVV_l7UgQAjG6p_IY5ib-gdPXS1tJD787PP7Sbv_U&e=>
>
> --
> Hope this helps,
> Bruce Gray (Util of PerlMonks)
RE: DateTime: (now.Int) always 37 seconds off from (now)
Bruce,
Asked for elegant. Received elegant.
raku -e 'my $inst = now; put DateTime.new($inst).local, "\t",
DateTime.new($inst).truncated-to("second").local;'
2025-08-29T10:57:31.276115-04:002025-08-29T10:57:31-04:00
.truncated-to didn’t jump out at me when scanning class DateTime | Raku
Documentation<https://docs.raku.org/type/DateTime>, but I’ve got it now.
Thanks!
Mark
From: Bruce Gray
Sent: Friday, August 29, 2025 10:24 AM
To: Mark Devine
Cc: perl6-users
Subject: Re: DateTime: (now.Int) always 37 seconds off from (now)
On Aug 29, 2025, at 09:14, Mark Devine
mailto:[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:
-MM-DDTHH:MM:SS-04:00
not this format:
-MM-DDTHH: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<https://urldefense.proofpoint.com/v2/url?u=https-3A__docs.raku.org_type_DateTime-23method-5Ftruncated-2Dto&d=DwMFaQ&c=euGZstcaTDllvimEN8b7jXrwqOf-v5A_CdpgnVfiiMM&r=thT0VsM9yJlPPLROt23gXb6x82v5JicoCnxKT8v5YUo&m=IUEIKGuypZHWmV48ZWHC1oCTBivDAGisVF0N2rNmN81DXrTspMZbZOC9rMYYDp48&s=_EwVV_l7UgQAjG6p_IY5ib-gdPXS1tJD787PP7Sbv_U&e=>
--
Hope this helps,
Bruce Gray (Util of PerlMonks)
Re: DateTime: (now.Int) always 37 seconds off from (now)
Take a look at
https://www.ipses.com/eng/in-depth-analysis/standard-of-time-definition/
Current time of each standard
The table below shows the current time according mentioned standards:
UTC 2025-08-29 16:17:40
GPS 2025-08-29 16:17:58
LORAN 2025-08-29 16:18:07
TAI 2025-08-29 16:18:17
-y
On Fri, Aug 29, 2025 at 11:05 AM Mark Devine wrote:
> Bruce,
>
>
>
> Asked for elegant. Received elegant.
>
>
>
> raku -e 'my $inst = now; put DateTime.new($inst).local, "\t",
> DateTime.new($inst).truncated-to("second").local;'
>
> 2025-08-29T10:57:31.276115-04:002025-08-29T10:57:31-04:00
>
>
>
> .truncated-to didn’t jump out at me when scanning class DateTime | Raku
> Documentation <https://docs.raku.org/type/DateTime>, but I’ve got it now.
>
>
>
> Thanks!
>
>
>
> Mark
>
>
>
>
>
> *From:* Bruce Gray
> *Sent:* Friday, August 29, 2025 10:24 AM
> *To:* Mark Devine
> *Cc:* perl6-users
> *Subject:* Re: DateTime: (now.Int) always 37 seconds off from (now)
>
>
>
>
>
>
>
> On Aug 29, 2025, at 09:14, Mark Devine 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:
>
> -MM-DDT*HH:MM:SS*-04:00
>
> not this format:
>
> -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
> <https://urldefense.proofpoint.com/v2/url?u=https-3A__docs.raku.org_type_DateTime-23method-5Ftruncated-2Dto&d=DwMFaQ&c=euGZstcaTDllvimEN8b7jXrwqOf-v5A_CdpgnVfiiMM&r=thT0VsM9yJlPPLROt23gXb6x82v5JicoCnxKT8v5YUo&m=IUEIKGuypZHWmV48ZWHC1oCTBivDAGisVF0N2rNmN81DXrTspMZbZOC9rMYYDp48&s=_EwVV_l7UgQAjG6p_IY5ib-gdPXS1tJD787PP7Sbv_U&e=>
>
>
>
> --
>
> Hope this helps,
>
> Bruce Gray (Util of PerlMonks)
>
Re: DateTime: (now.Int) always 37 seconds off from (now)
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
wrote:
>
>
> On Aug 29, 2025, at 09:14, Mark Devine 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:
> -MM-DDT*HH:MM:SS*-04:00
> not this format:
> -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
Re: DateTime: (now.Int) always 37 seconds off from (now)
> On Aug 29, 2025, at 09:14, Mark Devine 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:
> -MM-DDTHH:MM:SS-04:00
> not this format:
> -MM-DDTHH: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)
