Skip to content

Commit

Permalink
Add support for subseconds support in ISO 8601, see #126948
Browse files Browse the repository at this point in the history
  • Loading branch information
Skarsnik committed Dec 17, 2015
1 parent 6b1b3ef commit 9a5a7db
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/core/Temporal.pm
Expand Up @@ -256,7 +256,7 @@ my class DateTime does Dateish {
}

multi method new(Str $format, :$timezone is copy = 0, :&formatter=&default-formatter) {
$format ~~ /^ (\d**4) '-' (\d\d) '-' (\d\d) <[Tt]> (\d\d) ':' (\d\d) ':' (\d\d) (<[Zz]> || (<[\-\+]>) (\d\d) (':'? (\d\d))? )? $/
$format ~~ /^ (\d**4) '-' (\d\d) '-' (\d\d) <[Tt]> (\d\d) ':' (\d\d) ':' (\d\d[<[\.,]>\d ** 1..6]?) (<[Zz]> || (<[\-\+]>) (\d\d) (':'? (\d\d))? )? $/
or X::Temporal::InvalidFormat.new(
invalid-str => $format,
target => 'DateTime',
Expand Down Expand Up @@ -468,7 +468,11 @@ my class DateTime does Dateish {
}

method Str() {
&!formatter(self)
if $!second.floor == $!second {
&!formatter(self)
} else {
&!formatter === &default-formatter ?? &!formatter(self, :subseconds) !! &!formatter(self);
}
}

multi method perl(DateTime:D:) {
Expand Down

0 comments on commit 9a5a7db

Please sign in to comment.