.\" Automatically generated by Pod::Man 4.11 (Pod::Simple 3.35)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings. \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote. \*(C+ will
.\" give a nicer C++. Capital omega is used to do unbreakable dashes and
.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
.\" nothing in troff, for use with C<>.
.tr \(*W-
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
. ds -- \(*W-
. ds PI pi
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
. ds L" ""
. ds R" ""
. ds C` ""
. ds C' ""
'br\}
.el\{\
. ds -- \|\(em\|
. ds PI \(*p
. ds L" ``
. ds R" ''
. ds C`
. ds C'
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\"
.\" If the F register is >0, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.\"
.\" Avoid warning from groff about undefined register 'F'.
.de IX
..
.nr rF 0
.if \n(.g .if rF .nr rF 1
.if (\n(rF:(\n(.g==0)) \{\
. if \nF \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. if !\nF==2 \{\
. nr % 0
. nr F 2
. \}
. \}
.\}
.rr rF
.\" ========================================================================
.\"
.IX Title "Mojo::Date 3"
.TH Mojo::Date 3 "2023-03-08" "perl v5.26.3" "User Contributed Perl Documentation"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH "NAME"
Mojo::Date \- HTTP date
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
.Vb 1
\& use Mojo::Date;
\&
\& # Parse
\& my $date = Mojo::Date\->new(\*(AqSun, 06 Nov 1994 08:49:37 GMT\*(Aq);
\& say $date\->epoch;
\&
\& # Build
\& my $date = Mojo::Date\->new(time + 60);
\& say "$date";
.Ve
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
Mojo::Date implements \s-1HTTP\s0 date and time functions, based on \s-1RFC 7230\s0 <https://tools.ietf.org/html/rfc7230>, \s-1RFC
7231\s0 <https://tools.ietf.org/html/rfc7231> and \s-1RFC 3339\s0 <https://tools.ietf.org/html/rfc3339>.
.SH "ATTRIBUTES"
.IX Header "ATTRIBUTES"
Mojo::Date implements the following attributes.
.SS "epoch"
.IX Subsection "epoch"
.Vb 2
\& my $epoch = $date\->epoch;
\& $date = $date\->epoch(784111777);
.Ve
.PP
Epoch seconds, defaults to the current time.
.SH "METHODS"
.IX Header "METHODS"
Mojo::Date inherits all methods from Mojo::Base and implements the following new ones.
.SS "new"
.IX Subsection "new"
.Vb 2
\& my $date = Mojo::Date\->new;
\& my $date = Mojo::Date\->new(\*(AqSun Nov 6 08:49:37 1994\*(Aq);
.Ve
.PP
Construct a new Mojo::Date object and \*(L"parse\*(R" date if necessary.
.SS "parse"
.IX Subsection "parse"
.Vb 1
\& $date = $date\->parse(\*(AqSun Nov 6 08:49:37 1994\*(Aq);
.Ve
.PP
Parse date.
.PP
.Vb 3
\& # Epoch
\& say Mojo::Date\->new(\*(Aq784111777\*(Aq)\->epoch;
\& say Mojo::Date\->new(\*(Aq784111777.21\*(Aq)\->epoch;
\&
\& # RFC 822/1123
\& say Mojo::Date\->new(\*(AqSun, 06 Nov 1994 08:49:37 GMT\*(Aq)\->epoch;
\&
\& # RFC 850/1036
\& say Mojo::Date\->new(\*(AqSunday, 06\-Nov\-94 08:49:37 GMT\*(Aq)\->epoch;
\&
\& # Ansi C asctime()
\& say Mojo::Date\->new(\*(AqSun Nov 6 08:49:37 1994\*(Aq)\->epoch;
\&
\& # RFC 3339
\& say Mojo::Date\->new(\*(Aq1994\-11\-06T08:49:37Z\*(Aq)\->epoch;
\& say Mojo::Date\->new(\*(Aq1994\-11\-06T08:49:37\*(Aq)\->epoch;
\& say Mojo::Date\->new(\*(Aq1994\-11\-06T08:49:37.21Z\*(Aq)\->epoch;
\& say Mojo::Date\->new(\*(Aq1994\-11\-06T08:49:37+01:00\*(Aq)\->epoch;
\& say Mojo::Date\->new(\*(Aq1994\-11\-06T08:49:37\-01:00\*(Aq)\->epoch;
.Ve
.SS "to_datetime"
.IX Subsection "to_datetime"
.Vb 1
\& my $str = $date\->to_datetime;
.Ve
.PP
Render \s-1RFC 3339\s0 <https://tools.ietf.org/html/rfc3339> date and time.
.PP
.Vb 2
\& # "1994\-11\-06T08:49:37Z"
\& Mojo::Date\->new(784111777)\->to_datetime;
\&
\& # "1994\-11\-06T08:49:37.21Z"
\& Mojo::Date\->new(784111777.21)\->to_datetime;
.Ve
.SS "to_string"
.IX Subsection "to_string"
.Vb 1
\& my $str = $date\->to_string;
.Ve
.PP
Render date suitable for \s-1HTTP\s0 messages.
.PP
.Vb 2
\& # "Sun, 06 Nov 1994 08:49:37 GMT"
\& Mojo::Date\->new(784111777)\->to_string;
.Ve
.SH "OPERATORS"
.IX Header "OPERATORS"
Mojo::Date overloads the following operators.
.SS "bool"
.IX Subsection "bool"
.Vb 1
\& my $bool = !!$date;
.Ve
.PP
Always true.
.SS "stringify"
.IX Subsection "stringify"
.Vb 1
\& my $str = "$date";
.Ve
.PP
Alias for \*(L"to_string\*(R".
.SH "SEE ALSO"
.IX Header "SEE ALSO"
Mojolicious, Mojolicious::Guides, <https://mojolicious.org>.