Date
ErrorsCollection

Date

Synthesised documentation from type/Instant type/Date type/DateTime type/Str

From type/Instant

See Original text in context

method Date(Instant:D: --> Date:D)

Coerces the invocant to Date.

my $i = "/etc/passwd".IO.modified;
say $i;             # OUTPUT: «Instant:1451489025.878018␤» 
say $i.Date;        # OUTPUT: «2015-12-30␤»

From type/Date

See Original text in context

method Date(--> Date)

Returns the invocant.

say Date.new('2015-12-24').Date;  # OUTPUT: «2015-12-24␤» 
say Date.Date;                    # OUTPUT: «(Date)␤»

From type/DateTime

See Original text in context

multi method Date(DateTime:U --> Date:U)
multi method Date(DateTime:D --> Date:D)

Converts the invocant to Date.

say DateTime.new("2012-02-29T12:34:56.946314Z").Date# OUTPUT: «2012-02-29␤» 
say DateTime.Date;                                    # OUTPUT: «(Date)␤» 

From type/Str

See Original text in context

method Date(Str:D:)

Coerces a Str to a Date object, provided the string is properly formatted. Date(Str) also works.

Examples:

say '2015-11-24'.Date.year;  # OUTPUT: «2015␤» 
say Date('2015-11-24').year# OUTPUT: «2015␤»