formatter
ErrorsCollection

formatter

Synthesised documentation from type/Dateish

From type/Dateish

See Original text in context

method formatter(Dateish:D:)

Returns the formatting function which is used for conversion to Str. If none was provided at object construction, a default formatter is used. In that case the method will return a Callable type object.

The formatting function is called by DateTime method Str with the invocant as its only argument.

my $dt = Date.new('2015-12-31');  # (no formatter specified) 
say $dt.formatter.^name;          # OUTPUT: «Callable␤» 
my $us-format = sub ($self{ sprintf "%02d/%02d/%04d".month.day.year given $self};
$dt = Date.new('2015-12-31'formatter => $us-format);
say $dt.formatter.^name;           # OUTPUT: «Sub␤» 
say $dt;                          # OUTPUT: «12/31/2015␤»