Skip to content

Instantly share code, notes, and snippets.

@felher
Created August 2, 2012 21:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save felher/3240741 to your computer and use it in GitHub Desktop.
Save felher/3240741 to your computer and use it in GitHub Desktop.
Patch for Date. Otherwise Date.new(year => 2012) fails because $month/$day are of type Any by default and therefore not compatible with their Int-typed instance variables and because they'd be uninitialized
From 6beffa8d2f4b18fcabd0c83a93310bc70a122ea3 Mon Sep 17 00:00:00 2001
From: Felix Herrmann <felix@herrmann-koenigsberg.de>
Date: Thu, 2 Aug 2012 20:07:03 +0200
Subject: [PATCH] [Temporal] change constructor of Date to use default values
for year/month/day
---
src/core/Temporal.pm | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/core/Temporal.pm b/src/core/Temporal.pm
index ad844f8..5824ee6 100644
--- a/src/core/Temporal.pm
+++ b/src/core/Temporal.pm
@@ -421,21 +421,21 @@ my class Date does Dateish {
has Int $.year;
has Int $.month = 1;
has Int $.day = 1;
has Int $.daycount;
method !set-daycount($dc) { $!daycount = $dc }
method get-daycount { $!daycount }
- multi method new(:$year!, :$month, :$day) {
+ multi method new(:$year!, :$month = 1, :$day = 1) {
my $d = self.bless(*, :$year, :$month, :$day);
$d.check-date;
$d!set-daycount(self.daycount-from-ymd($year,$month,$day));
$d;
}
multi method new($year, $month, $day) {
self.new(:$year, :$month, :$day);
}
--
1.7.8.6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment