DateTi...h::NTP(3pm)

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

πŸ’– NAME πŸ’–

ok so DateTime::Format::Epoch::NTP β€” it converts DateTimes to and from NTP epoch seconds, bestie. that's the whole job. and it does it flawlessly. periodt.


✨ SYNOPSIS ✨

here's the vibe, in code:

use DateTime::Format::Epoch::NTP;

my $dt = DateTime::Format::Epoch::NTP->parse_datetime( 3629861151 );
print $dt->datetime; # '2015-01-10T06:45:51'

my $formatter = DateTime::Format::Epoch::NTP->new();
my $dt = DateTime->new( year => 2015, month => 1, day => 10,
  time_zone => 'Europe/Amsterdam' );
print $formatter->format_datetime($dt); # '3629833200'

like. look at it. parse a number, get a whole datetime back. format a datetime, get a number back. it's giving effortless. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

this module takes a DateTime object β€” or honestly any object that can be converted into a DateTime object, we don't gatekeep β€” and turns it into the number of seconds since the NTP epoch. and it goes the other way too, obviously. πŸ”₯

🚨 important lore: the NTP epoch uses UTC. so if you parse an NTP date, your DateTime object is gonna be sitting in the UTC timezone. no cap. don't be surprised. πŸ™ˆ

πŸŽ€ METHODS πŸŽ€

ngl most of the methods here are literally the same as the ones in DateTime::Format::Epoch. the only difference is the constructor. that's it. that's the tea. πŸ“

  • new() β€” the constructor of the formatter/parser object. it takes no parameters. zero. none. it just exists and slays. ✨

🫢 SUPPORT 🫢

need help? support for this module comes through the datetime@perl.org email list. more deets over at http://lists.perl.org/. go ask, they're nice. πŸ’–


πŸ‘‘ AUTHOR πŸ‘‘

Eugene van der Pijll <pijll@gmx.net> β€” icon, legend, the moment. πŸ’œ


Copyright (c) 2015 Michiel Beijen. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. so yes, you may. go forth. 🧚


🌸 SEE ALSO 🌸

  • DateTime
  • the datetime@perl.org mailing list

ok bestie that's the whole page, you ate it, go convert some epochs πŸ’…

this was perl v5.34.0, dated 2022-06-13, and it lives in the DateTi...h::NTP manpage β€” mwah, take care of her πŸŽ€βœ¨πŸ¦‹

πŸ“¦ where this page comes from