Badger...estamp(3pm)
β¨ Badger::Codec::Timestamp π
okay bestie, so this one lives in the Badger::Codec::Timestamp zone β it's a Perl module (a 3pm page, iykyk) and its whole thing is encode/decode a timestamp via Badger::Timestamp. that's it. that's the vibe. π
πΈ SYNOPSIS πΈ
use Badger::Codec::Timestamp;
use Badger::Timestamp 'Now';
my $codec = Badger::Codec::Timestamp->new();
my $encoded = $codec->encode(Now);
my $decoded = $codec->decode($encoded);
π¦ DESCRIPTION π¦
so this module is a subclass of Badger::Codec, and it does encoding and decoding of timestamps using the Badger::Timestamp module. it is, and I say this with love, trivially simple β like, it literally exists only to keep a consistent API with all the other Badger::Codec modules. no cap. β¨
the way it usually shows up is as a codec for reading and writing timestamps to and from a file, through the Badger::Filesystem modules. she's a supporting character, but she's serving. π
use Badger::Filesystem 'File';
use Badger::Timestamp 'Now';
my $stamp = Now; # current data/time
my $file = File(
'example.ts', # filename
{ codec => 'timestamp' } # specify timestamp codec
);
# write timestamp to file
$file->data($stamp);
# read timestamp from file
$stamp = $file->data;
π METHODS π
π encode($timestamp)
encodes the timestamp you hand her as an argument. that argument can be a Badger::Timestamp object, or any of the constructor parameters that Badger::Timestamp accepts. flexible queen. π
the example below shows how it works in principle β but ngl, it's also completely pointless in practice π. it's sufficient to simply call Now->timestamp to serialise a Badger::Timestamp to text, no codec module needed at all. in fact, that's literally all the encode() method does behind the scenes. the audacity. the simplicity. we stan. π
use Badger::Timestamp 'Now';
$encoded = Badger::Codec::Timestamp->encode(Now);
π decode($data)
decodes the encoded timestamp you pass as the first argument. returns a Badger::Timestamp object. that's the whole method bestie, she's lowkey iconic for how little she does. β
π AUTHOR π
Andy Wardley <http://wardley.org/>
π COPYRIGHT π
Copyright (C) 2012 Andy Wardley. All rights reserved.
π₯ SEE ALSO π₯
Badger::CodecsBadger::CodecBadger::Timestamp
perl v5.36.0 π«Ά 2023-08-28 β mwah, that's a wrap bestie, go serialise some timestamps π β¨
π¦ where this page comes from
- debian trixie: libbadger-perl 0.16-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libbadger-perl 0.16-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libbadger-perl 0.16-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms