GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  MOJO::DATE (3)

.ds Aq ’

NAME

Mojo::Date - HTTP date

CONTENTS

SYNOPSIS



  use Mojo::Date;

  # Parse
  my $date = Mojo::Date->new(Sun, 06 Nov 1994 08:49:37 GMT);
  say $date->epoch;

  # Build
  my $date = Mojo::Date->new(time + 60);
  say "$date";



DESCRIPTION

Mojo::Date implements HTTP date and time functions, based on RFC 7230 <http://tools.ietf.org/html/rfc7230>, RFC 7231 <http://tools.ietf.org/html/rfc7231> and RFC 3339 <http://tools.ietf.org/html/rfc3339>.

ATTRIBUTES

Mojo::Date implements the following attributes.

    epoch



  my $epoch = $date->epoch;
  $date     = $date->epoch(784111777);



Epoch seconds, defaults to the current time.

METHODS

Mojo::Date inherits all methods from Mojo::Base and implements the following new ones.

    new



  my $date = Mojo::Date->new;
  my $date = Mojo::Date->new(Sun Nov  6 08:49:37 1994);



Construct a new Mojo::Date object and parse date if necessary.

    parse



  $date = $date->parse(Sun Nov  6 08:49:37 1994);



Parse date.



  # Epoch
  say Mojo::Date->new(784111777)->epoch;
  say Mojo::Date->new(784111777.21)->epoch;

  # RFC 822/1123
  say Mojo::Date->new(Sun, 06 Nov 1994 08:49:37 GMT)->epoch;

  # RFC 850/1036
  say Mojo::Date->new(Sunday, 06-Nov-94 08:49:37 GMT)->epoch;

  # Ansi C asctime()
  say Mojo::Date->new(Sun Nov  6 08:49:37 1994)->epoch;

  # RFC 3339
  say Mojo::Date->new(1994-11-06T08:49:37Z)->epoch;
  say Mojo::Date->new(1994-11-06T08:49:37)->epoch;
  say Mojo::Date->new(1994-11-06T08:49:37.21Z)->epoch;
  say Mojo::Date->new(1994-11-06T08:49:37+01:00)->epoch;
  say Mojo::Date->new(1994-11-06T08:49:37-01:00)->epoch;



    to_datetime



  my $str = $date->to_datetime;



Render RFC 3339 <http://tools.ietf.org/html/rfc3339> date and time.



  # "1994-11-06T08:49:37Z"
  Mojo::Date->new(784111777)->to_datetime;

  # "1994-11-06T08:49:37.21Z"
  Mojo::Date->new(784111777.21)->to_datetime;



    to_string



  my $str = $date->to_string;



Render date suitable for HTTP messages.



  # "Sun, 06 Nov 1994 08:49:37 GMT"
  Mojo::Date->new(784111777)->to_string;



OPERATORS

Mojo::Date overloads the following operators.

    bool



  my $bool = !!$date;



Always true.

    stringify



  my $str = "$date";



Alias for to_string.

SEE ALSO

Mojolicious, Mojolicious::Guides, <http://mojolicious.org>.
Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 MOJO::DATE (3) 2016-03-15

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.