[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-smalltalk] DateTime
From: |
Paolo Bonzini |
Subject: |
Re: [Help-smalltalk] DateTime |
Date: |
Thu, 26 Nov 2009 20:04:00 +0100 |
User-agent: |
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.4pre) Gecko/20090922 Fedora/3.0-3.9.b4.fc12 Lightning/1.0pre Thunderbird/3.0b4 |
On 11/26/2009 05:43 PM, Stefan Izota wrote:
Hi all,
I did not find a way to convert seconds to DateTime so I wrote something
like this:
DateTime class extend [
fromSeconds: seconds [
| date time |
date := Date fromSeconds: seconds.
time := Time fromSeconds: (seconds - date asSeconds).
^ DateTime date: date time: time
]
]
Is there other way to do this?
No, you patch is a good idea and I'll apply it (together with
fromSeconds:offset:). Another possibility is
diff --git a/kernel/AnsiDates.st b/kernel/AnsiDates.st
index b2c5c38..1314d85 100644
--- a/kernel/AnsiDates.st
+++ b/kernel/AnsiDates.st
@@ -57,8 +57,8 @@ Date subclass: DateTime [
offset field to ofs (a Duration)."
<category: 'instance creation (non-ANSI)'>
- ^(self fromDays: days)
- setSeconds: secs;
+ ^(self fromDays: days + (secs // 86400))
+ setSeconds: secs \\ 86400;
setOffset: ofs
]
Paolo