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://docs.raku.org/type/DateTime>, 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)