equal
deleted
inserted
replaced
66 Filename |
66 Filename |
67 " |
67 " |
68 ! ! |
68 ! ! |
69 |
69 |
70 !Time class methodsFor:'instance creation'! |
70 !Time class methodsFor:'instance creation'! |
71 |
|
72 fromSeconds:secondsSinceMidnight |
|
73 "return a new Time, which represents the number of seconds since midNight. |
|
74 Be careful, time wraps - if the number of seconds exceeds the number of seconds |
|
75 in a day, a time relative to another days midnight is returned. |
|
76 (i.e. (Time fromSeconds:0) = (Time fromSeconds:24*3600)" |
|
77 |
|
78 |s| |
|
79 |
|
80 s := secondsSinceMidnight \\ (3600 * 24). |
|
81 ^ self |
|
82 hours:(s // 3600) |
|
83 minutes:((s \\ 3600) // 60) |
|
84 seconds:((s \\ 3600) \\ 60) |
|
85 |
|
86 " |
|
87 Time fromSeconds:0 |
|
88 Time fromSeconds:3675 |
|
89 Time fromSeconds:36000 |
|
90 Time fromSeconds:72000 |
|
91 Time fromSeconds:96000 |
|
92 Time fromSeconds:360000 |
|
93 " |
|
94 |
|
95 "Modified: 8.10.1996 / 19:32:11 / cg" |
|
96 ! |
|
97 |
71 |
98 hour:h minutes:m seconds:s |
72 hour:h minutes:m seconds:s |
99 "return an instance of Time representing the given time. |
73 "return an instance of Time representing the given time. |
100 See also Time now / Date today / AbsoluteTime now. |
74 See also Time now / Date today / AbsoluteTime now. |
101 Obsolete: please use #hours:minutes:seconds:" |
75 Obsolete: please use #hours:minutes:seconds:" |
232 formatString24 |
206 formatString24 |
233 "return the format string used to format european times (and other areas)" |
207 "return the format string used to format european times (and other areas)" |
234 |
208 |
235 ^ '%h:%m:%s' |
209 ^ '%h:%m:%s' |
236 ! ! |
210 ! ! |
237 |
|
238 |
211 |
239 !Time methodsFor:'Compatibility - Squeak'! |
212 !Time methodsFor:'Compatibility - Squeak'! |
240 |
213 |
241 intervalString |
214 intervalString |
242 "Treat the time as a difference. |
215 "Treat the time as a difference. |
624 self setSeconds:(millis // 1000) |
597 self setSeconds:(millis // 1000) |
625 ! |
598 ! |
626 |
599 |
627 setSeconds:secs |
600 setSeconds:secs |
628 "set my time given seconds since midnight. |
601 "set my time given seconds since midnight. |
629 Notice the modulu opeartions here - there c annot be a time behond 24hours |
602 Notice the modulu operations here - there cannot be a time behond 24hours |
630 (use TimeDuration, if you need that)." |
603 (use TimeDuration, if you need that)." |
631 |
604 |
632 secs < 0 ifTrue:[ |
605 secs < 0 ifTrue:[ |
633 timeEncoding := (24 * 3600) - (secs negated \\ (24 * 3600)) |
606 timeEncoding := (24 * 3600) - (secs negated \\ (24 * 3600)) |
634 ] ifFalse:[ |
607 ] ifFalse:[ |
637 timeEncoding > (24 * 3600) ifTrue:[ |
610 timeEncoding > (24 * 3600) ifTrue:[ |
638 timeEncoding := timeEncoding \\ (24 * 3600). |
611 timeEncoding := timeEncoding \\ (24 * 3600). |
639 ] |
612 ] |
640 |
613 |
641 " |
614 " |
|
615 Time basicNew setSeconds:0 |
|
616 Time fromSeconds:3601 |
642 Time now seconds |
617 Time now seconds |
643 Time now timeEncoding |
618 Time now timeEncoding |
644 (Time now addDays:5) seconds |
619 (Time now addDays:5) seconds |
645 (Time now addDays:5) timeEncoding |
620 (Time now addDays:5) timeEncoding |
646 " |
621 " |
658 and should not be used outside." |
633 and should not be used outside." |
659 |
634 |
660 timeEncoding := encoding |
635 timeEncoding := encoding |
661 ! ! |
636 ! ! |
662 |
637 |
663 |
|
664 !Time class methodsFor:'documentation'! |
638 !Time class methodsFor:'documentation'! |
665 |
639 |
666 version |
640 version |
667 ^ '$Header: /cvs/stx/stx/libbasic/Time.st,v 1.59 2002-11-26 13:52:26 cg Exp $' |
641 ^ '$Header: /cvs/stx/stx/libbasic/Time.st,v 1.60 2003-02-07 09:52:28 penk Exp $' |
668 ! ! |
642 ! ! |