# New Ticket Created by  Timothy Totten 
# Please include the string:  [perl #75550]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=75550 >


>From da698565145af4221d28dd81d44a741b66c1d56c Mon Sep 17 00:00:00 2001
From: Timothy Totten <2...@huri.net>
Date: Thu, 3 Jun 2010 10:40:25 -0700
Subject: [PATCH] Implemented Date.new(::DateTime) and DateTime.Date()
methods.

---
 src/core/Date.pm     |    4 ++++
 src/core/Temporal.pm |    5 +++++
 2 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/src/core/Date.pm b/src/core/Date.pm
index 3667756..e2a1327 100644
--- a/src/core/Date.pm
+++ b/src/core/Date.pm
@@ -86,6 +86,10 @@ class Date {
         self.bless(*, :$year, :$month, :$day, :$daycount);
     }

+    multi method new(::DateTime $dt) {
+        self.bless(*, :year($dt.year), :month($dt.month), :day($dt.day));
+    }
+
     multi method today() {
         my $dt = ::DateTime.now();
         self.bless(*, :year($dt.year), :month($dt.month), :day($dt.day));
diff --git a/src/core/Temporal.pm b/src/core/Temporal.pm
index 891636f..b5f8289 100644
--- a/src/core/Temporal.pm
+++ b/src/core/Temporal.pm
@@ -254,6 +254,11 @@ class DateTime {
     method set-second($second)         { self.set(:$second) }
     method set-time-zone($time-zone)   { self.set(:$time-zone) }
     method set-formatter($formatter)   { self.set(:$formatter) }
+
+    method Date() {
+        return ::Date.new(self);
+    }
+
 }

 =begin pod
-- 
1.7.0.4

Reply via email to