Skip to content

Commit 02e6da7

Browse files
committed
Document that DateTime.new("YYYY-MM-DD") also works
and consequently, "YYYY-MM-DD".DateTime does as well
1 parent d8f6e7b commit 02e6da7

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

doc/Type/DateTime.pod6

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@ Since Rakudo release 2022.03, the C<day> parameter can be a C<Callable>, with
9999
C<*> returning the last day in the month, and C<*-n> returning the last but
100100
C<n>.
101101
102+
Since Rakudo release 2022.07, it is also possible to just specify a
103+
"YYYY-MM-DD" string to indicate midnight on the given date.
104+
105+
say DateTime.new("2023-03-04"); # OUTPUT: «2023-03-04T00:00:00Z␤»
106+
102107
=head2 method now
103108
104109
method now(:$timezone = $*TZ, :&formatter --> DateTime:D)

doc/Type/Str.pod6

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1327,6 +1327,8 @@ C<Numeric>.
13271327
13281328
method Version(Str:D: --> Version:D)
13291329
1330+
Available as of the 2020.01 release of the Rakudo compiler.
1331+
13301332
Coerces the string to L<Version|/type/Version>.
13311333
13321334
This could be used for L<type coercion in
@@ -1335,12 +1337,12 @@ signature|/language/signatures#Coercion_type>, as for example:
13351337
sub f(Version(Str) $want-version) { say $want-version.^name };
13361338
f "1.2.3"; # OUTPUT: «Version␤»
13371339
1338-
Available as of the 2020.01 release of the Rakudo compiler.
1339-
13401340
=head2 method Date
13411341
13421342
method Date(Str:D:)
13431343
1344+
Available as of the 2020.05 release of the Rakudo compiler.
1345+
13441346
Coerces a C<Str> to a L«C«Date»|/type/Date» object, provided the string is
13451347
properly formatted. C«Date(Str)» also works.
13461348
@@ -1349,12 +1351,12 @@ Examples:
13491351
say '2015-11-24'.Date.year; # OUTPUT: «2015␤»
13501352
say Date('2015-11-24').year; # OUTPUT: «2015␤»
13511353
1352-
Available as of the 2020.05 release of the Rakudo compiler.
1353-
13541354
=head2 method DateTime
13551355
13561356
method DateTime(Str:D:)
13571357
1358+
Available as of the 2020.05 release of the Rakudo compiler.
1359+
13581360
Coerces a C<Str> to a L«C«DateTime»|/type/DateTime» object, provided the
13591361
string is properly formatted. C«DateTime(Str)» also works.
13601362
@@ -1363,6 +1365,9 @@ Examples:
13631365
say ('2012-02-29T12:34:56Z').DateTime.hour; # OUTPUT: «12␤»
13641366
say DateTime('2012-02-29T12:34:56Z').hour; # OUTPUT: «12␤»
13651367
1366-
Available as of the 2020.05 release of the Rakudo compiler.
1368+
Since Rakudo release 2022.07, it is also possible to just specify a
1369+
"YYYY-MM-DD" string to indicate midnight on the given date.
1370+
1371+
say "2023-03-04".DateTime; # OUTPUT: «2023-03-04T00:00:00Z␤»
13671372
13681373
=end pod

0 commit comments

Comments
 (0)