PFT::Date(3)
π PFT::Date π
okay bestie, so this is PFT::Date(3) β a lil Perl module from the User Contributed Perl Documentation corner of the universe, and it's literally just here to hold a date for you. that's it. that's the job. π
β¨ NAME β¨
PFT::Date β the representation of a date. that's the whole vibe. a date, but as an object, being all cute and structured. π
πΈ SYNOPSIS πΈ
here's how you actually use it, no gatekeeping:
PFT::Date->new(2016, 12, 10)
PFT::Date->from_spec(
d => 12,
m => 'june', # human friendly
# missing ones (e.g. year) filled with today's year.
)
PFT::Date->from_string('1955-11-05');
like, you can make one the normal way, or you can be all chill and human about it with from_spec (and yes you can literally just say 'june', the module gets it), or you can parse one straight out of a string. iconic behaviour honestly. π
π¦ DESCRIPTION π¦
so PFT::Date is defined as a blessed array reference. and the way that array is laid out is not random, it's giving very deliberate:
- the first element is the year
- the second element is the month
- the third element is the day
three slots, three facts, no notes. π
π Properties π
π y
Year getter. she gets you the year. that's it. that's the whole job.
π m
Month getter. gets the month. slay.
π d
Day getter. gets the day. consistent queen. π
π to_hash
returns a dictionary (a hash, bestie, we're in Perl) shaped like this:
{ y => ..., m => ..., d => ... }
all your date bits, nicely labelled, ready to be passed around. π
π repr
returns a string representing the date. and there's an optional parameter: a separator string. if you don't pass one, it just defaults to '-'. periodt.
PFT::Date->new(1,2,3)->repr eq '0001-02-03'
PFT::Date->new(1,2,3)->repr('/') eq '0001/02/03'
see how it zero-pads? four digits for the year, two for the month, two for the day? that's the β¨attention to detailβ¨ we love around here.
π derive
returns a copy of the PFT::Date object, but with the components you provide replaced. so like:
PFT::Date->new(1, 2, 3)->derive(m => undef)
is basically the same energy as:
PFT::Date->new(1, undef, 3)
you swap out a piece, you get a fresh new date back. the original stays untouched, no cap. π«Ά
π complete
checks if the date is complete β meaning it's got all three of year, month AND day. if anything's missing, it's not complete, and it'll tell you so. vibe check passed or failed, your call. π
heads up bestie: PFT::Date being a blessed array ref means the year, month and day live at positions 0, 1 and 2 β don't go poking around in there and expect something else. π
okay and for the lil sign-off, this whole thing is documented as PFT::Date(3), and the page is stamped with perl v5.42.0 and dated 2025-07-25 β so if you're reading this, that's the era you're in. go forth and represent some dates, you absolute main character. πβ¨ππ¦πΈπ
π¦ where this page comes from
- fedora 43: perl-PFT 1.4.1-18.fc43 Β· GPL-3.0-or-later
- fedora 44: perl-PFT 1.4.1-18.fc43 Β· GPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms