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 <m...@markdevine.com> 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:00 2025-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 <robertbrucegr...@gmail.com> > Sent: Friday, August 29, 2025 10:24 AM > To: Mark Devine <m...@markdevine.com> > Cc: perl6-users <perl6-us...@perl.org> > Subject: Re: DateTime: (now.Int) always 37 seconds off from (now) > > > > > On Aug 29, 2025, at 09:14, Mark Devine <m...@markdevine.com > <mailto:m...@markdevine.com>> 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-DDTHH:MM:SS-04:00 > not this format: > YYYY-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)