DateTime
ErrorsCollection

DateTime

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

From type/Instant

See Original text in context

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

Coerces the invocant to DateTime.

say now.DateTime;  # OUTPUT: «2017-05-09T14:02:58.147165Z␤»

From type/Date

See Original text in context

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

Converts the invocant to DateTime

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

From type/DateTime

See Original text in context

method DateTime(--> DateTime)

Returns the invocant.

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

From type/Str

See Original text in context

method DateTime(Str:D:)

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

Examples:

say ('2012-02-29T12:34:56Z').DateTime.hour# OUTPUT: «12␤» 
say DateTime('2012-02-29T12:34:56Z').hour;  # OUTPUT: «12␤»