Skip to content

Commit

Permalink
Streamline DateTime handling
Browse files Browse the repository at this point in the history
- main new logic now in .new($y,$m,$d,$h,$mi,$s,$t) which allows for coercion
- no special format for small/large years
- check-date/check-value helper functions removed
- fixed some cases where multiple of a unit name would not be accepted
- use native ints where possible
- optimized earlier/later a bit
- truncate-parts is now private method truncate-ymd
  • Loading branch information
lizmat committed Dec 23, 2015
1 parent 4355eac commit 047db4b
Show file tree
Hide file tree
Showing 3 changed files with 162 additions and 202 deletions.
7 changes: 6 additions & 1 deletion src/core/Date.pm
Expand Up @@ -52,7 +52,8 @@ my class Date does Dateish {
}

method truncated-to(Cool $unit) {
self.clone(|self.truncate-parts($unit));
self!VALID-UNIT($unit);
self!clone-without-validating(|self!truncate-ymd($unit));
}

method later(*%unit) {
Expand Down Expand Up @@ -108,6 +109,10 @@ my class Date does Dateish {
my %args = :$!year, :$!month, :$!day, %_;
self.new(|%args);
}
method !clone-without-validating(*%_) { # A premature optimization.
my %args = :$!year, :$!month, :$!day, %_;
self.bless(|%args);
}

method succ(Date:D:) {
self.new-from-daycount(self.daycount + 1);
Expand Down

0 comments on commit 047db4b

Please sign in to comment.