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
_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk