Date format: Difference between revisions

→‎{{header|Raku}}: switch to Date for libraryless example
(→‎{{header|Raku}}: switch to Date for libraryless example)
Line 2,687:
say strftime('%A, %B %d, %Y', $dt);</lang>
 
The DateTimebuilt-in classDate itselfand isDateTime built into Raku, andclasses comesboth withoffer support for the ISO format:
<lang perl6>my $dtd = DateTimeDate.nowtoday;
 
say $dtd.yyyy-mm-dd;</lang>
 
ItThey doesndon't include the longer format specified in the task, but you can always roll your own formatter instead of importing the library:
 
<lang perl6>my @months = <January February March April May June
Line 2,698:
my @days = <Sunday Monday Tuesday Wednesday Thursday Friday Saturday>;
my $us-long = sub ($self) { "{@days[$self.day-of-week]}, {@months[$self.month-1]} {$self.day}, {$self.year}" };
my $dtd = DateTimeDate.nowtoday :formatter($us-long);
 
say $dtd.yyyy-mm-dd; # still works
say $dtd # uses our formatter sub;</lang>
 
=={{header|Raven}}==
1,481

edits