PFT::Date(3)

πŸ“¦ version 1.4.1, in fedora 43, fedora 44

πŸ’– 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