#1 Yesterday 11:29

AndrewRH
Member
Registered: 2012-02-20
Posts: 10

Reformat ISO date-time formats with variable milliseconds

Regarding the improvements for the reformat date rule, specifically the ISO date-time formats, what is the formatting to find them?

The help page for the formatting only referred to a 'zzz' variable.

I tried using that but renamer only converted files that had thousandths of second (millisecond) not the iso ten-thousands of a second (fraction of second).

For example, I want to handle encoded dates in any of the formats: no fraction (0 characters nor a .), strict milliseconds (3 characters) or fractional (4 characters)...
2025-05-02 19:09:21+01:00
2025-05-02 19:09:21.457+01:00
2025-05-02 19:09:21.0756+01:00

I want to convert them all to 20250502-190921, for example.

Thanks again for your help

Last edited by AndrewRH (Yesterday 11:34)

Offline

#2 Yesterday 14:37

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,509

Re: Reformat ISO date-time formats with variable milliseconds

The first two formats (without milliseconds and with 3 digit milliseconds) can be handled with built-in formats, but the last one with fractional seconds (4 digits) doesn't have a native format.

It would be easier to just remove that variable part with milliseconds and the timezone (+01:00) with a Regular Expression rule.

1) Regular Expressions: Replace expression "\b(\.\d+)?\+01:00" with "" (skip extension)
2) Reformat Date: Convert to "yyyymmdd-hhnnss" from "yyyy-mm-dd hh:nn:ss", whole words only, skip extension

These rules will produce:

20250502-190921
20250502-190921
20250502-190921

Offline

Board footer

Powered by FluxBB