Skip to content

Instantly share code, notes, and snippets.

@ernstki
Created November 3, 2024 09:27
Show Gist options
  • Save ernstki/7e60edfd2156a7ad2bfcbbe47de4ed4f to your computer and use it in GitHub Desktop.
Save ernstki/7e60edfd2156a7ad2bfcbbe47de4ed4f to your computer and use it in GitHub Desktop.
Convert wacky date formats into ISO 8601 YYYY-MM-DD
#!/usr/bin/env perl
use v5.12;
use Time::Piece;
sub isoize {
# convert any wacky date formats to ISO 8601
my @dates;
foreach (@_) {
push @dates, Time::Piece->strptime($_, '%d %b %Y') if /\d+ \w+ \d{4}/;
# other date formats here
}
return map { $_->strftime('%F') } @dates;
}
main() unless caller();
sub main {
# whatever, maybe parse command-line options
undef;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment