Conver...FORMAT(3pm)

πŸ“¦
version 0.06 Β· 4 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– NAME πŸ’–

Convert::NLS_DATE_FORMAT β€” bestie, this is the little module that translates between Oracle's NLS_DATE_FORMAT and strftime format strings. Both directions. No cap. πŸ¦‹


✨ SYNOPSIS ✨

use Convert::NLS_DATE_FORMAT qw(oracle2posix posix2oracle);
my $strptime = oracle2posix($NLS_DATE_FORMAT);
$NLS_DATE_FORMAT = posix2oracle($strftime);

🌸 DESCRIPTION 🌸

Okay so here's the vibe: you got an Oracle NLS_DATE_FORMAT string and you want it to be a strptime format string? Say less. Or you want the opposite, going the other way? Also say less. This module does the translation for you and it is literally the whole point of its existence. πŸ‘‘

πŸŽ€ Functions πŸŽ€

oracle2posix

Takes an Oracle NLS_DATE_FORMAT string and converts it into a formatting string that's compatible with strftime or strptime. Slay. πŸ’…

my $format = oracle2posix('YYYY-MM-DD HH24:MI:SS'); # '%Y-%m-%d %H:%M:%S'

And here's the tea β€” character sequences that should NOT be translated can be wrapped up in double quotes, exactly as specified in the Oracle documentation. So they get left alone, untouched, protected, iconic. 🫢

my $format = oracle2posix('YYYY-MM-DD"T"HH24:MI:SS'); # '%Y-%m-%dT%H:%M:%S'

posix2oracle

The other direction, bestie! Takes a strftime or strptime formatting string and converts it into an Oracle NLS_DATE_FORMAT string. 🌈

Heads up though, real talk: it is possible to create strings which Oracle will not accept as valid NLS_DATE_FORMAT strings. So like… vibe check your output before you send it out into the world, okay? 😭
my $format = posix2oracle('%Y-%m-%d %H:%M:%S'); # 'YYYY-MM-DD HH24:MI:SS'

🌟 EXPORT 🌟

None by default. Zero. Nada. Nothing gets yeeted into your namespace uninvited, we are respectful like that. πŸ™ˆ

But if you ask for oracle2posix and posix2oracle? Then you get them, obviously, because you asked so nicely. πŸŽ€


πŸ‘€ SEE ALSO πŸ‘€

  • DateTime::Format::Oracle β€” go look at that one too, fr fr.

πŸ’œ AUTHOR πŸ’œ

Nathan Gray, <kolibrie@cpan.org> β€” the actual legend who wrote this. Give them their flowers. 🌸


Copyright (C) 2005, 2006, 2011, 2012, 2016 Nathan Gray

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.4 or, at your option, any later version of Perl 5 you may have available. 🫢


Okay that's the whole page bestie, you ate it. This was Convert::NLS_DATE_FORMAT from the perl v5.36.0 docs, dated 2022-11-19, straight out of the User Contributed Perl Documentation. Periodt. πŸ’…βœ¨

πŸ“¦ where this page comes from