Email::Date(3pm)

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

πŸ’– Email::Date β€” like, the whole vibe πŸ’–

okay bestie, welcome to Email::Date, a page from the User Contributed Perl Documentation section of the manual (that's the 3pm part, iykyk). It's literally called Find and Format Date Headers and honestly? It does exactly what it says on the tin. No cap. ✨


🌸 VERSION 🌸

This is version 1.104. Periodt.


πŸŽ€ SYNOPSIS πŸŽ€

here's the whole thing in action, bestie, look at it go:

use Email::Date;

my $email = join '', <>;
my $date  = find_date($email);
print $date->ymd;

my $header = format_date($date->epoch);

Email::Simple->create(
    header => [
        Date => $header,
    ],
    body => '...',
);

like. it's giving effortless. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

Achtung! ⚠️ Heads up, babe β€” you'll probably be fine just using Email::Date::Format to produce dates, or Date::Parse to parse them. This module isn't much needed anymore, but it does still provide find_date, which we'll get into below. πŸ‘‡

so. RFC 2822 defines the Date: header. It declares that header a required part of an email message β€” required!! The syntax for date headers is, like, clearly laid out and everything. But still (and yes the original says "Stil", we're keeping that typo, it's iconic πŸ’€) β€” even a perfectly planned world has storms. 😭

The truth is: many programs get it wrong. Very wrong. Or they just... don't include a Date: header at all. πŸ™ˆ Which then forces you to go looking elsewhere for the date and hoping you find something. Hoping!! the audacity.

For this reason, the tedious process of looking for a valid date has been encapsulated in this software. 🫢 And further β€” the process of creating RFC compliant date strings is also found in here too. We love a two-for-one.


✨ FUNCTIONS ✨

πŸ’œ find_date

my $time_piece = find_date $email;

find_date accepts an email message in any format Email::Abstract can understand. It looks through the email message and finds a date, converting it to a Time::Piece object.

If it can't find a date, it returns false. (sad, but valid πŸ₯²)

find_date is exported by default. slay.


πŸ’œ format_date

my $date = format_date; # now
my $date = format_date( time - 60*60 ); # one hour ago

format_date accepts an epoch value, such as the one returned by time. It returns a string representing the date and time of the input, as specified in RFC 2822. If no input value is provided, the current value of time is used. πŸ•

format_date is exported by default. also slay.


πŸ’œ format_gmdate

my $date = format_gmdate;

format_gmdate is identical to format_date, but it will return a string indicating the time in Greenwich Mean Time, rather than local time. 🌍 timezone girlie behaviour.

format_gmdate is exported on demand, but not by default. so you gotta ask for it, bestie.


πŸ‘‘ AUTHORS πŸ‘‘

  • Casey West
  • Ricardo SIGNES <rjbs@cpan.org>

This software is copyright (c) 2004 by Casey West.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.


and that's the whole page, bestie 🫢 this was Email::Date(3pm) from perl v5.36.0, dated 2022-11-27 β€” tysm for reading, mwah, go format some dates πŸ’‹βœ¨πŸŽ€

πŸ“¦ where this page comes from