73 ^ 0 |
73 ^ 0 |
74 ! ! |
74 ! ! |
75 |
75 |
76 !UtcTimestamp methodsFor:'converting'! |
76 !UtcTimestamp methodsFor:'converting'! |
77 |
77 |
|
78 asDate |
|
79 "return a Date object from the receiver. |
|
80 The returned date will only represent the day - not the timeOfDay. |
|
81 Notice: if you convert a local timestamp, you will get the local date; |
|
82 otherwise if you convert an utcTimestamp, you'll get the utc date." |
|
83 |
|
84 (osTime between:MinOSTime and:MaxOSTime) ifFalse:[ |
|
85 |dayDelta day0| |
|
86 |
|
87 dayDelta := osTime // (24 * 3600 * 1000). |
|
88 day0 := Epoch asDate. |
|
89 ^ day0 addDays:dayDelta. |
|
90 ]. |
|
91 ^ self timeInfo asDate |
|
92 |
|
93 " |
|
94 Timestamp now |
|
95 Timestamp now asDate |
|
96 (Timestamp now addTime:3600) asDate |
|
97 (Timestamp now addTime:3600) asTime |
|
98 Timestamp fromSeconds:(Timestamp now asSeconds + 3600) |
|
99 (Timestamp fromSeconds:(Timestamp now asSeconds + 3600)) asDate |
|
100 " |
|
101 ! |
|
102 |
78 asLocalTimestamp |
103 asLocalTimestamp |
79 "represent myself as a timestamp in the local timezone" |
104 "represent myself as a timestamp in the local timezone" |
80 |
105 |
81 ^ Timestamp fromOSTime:osTime |
106 ^ Timestamp fromOSTime:osTime |
|
107 ! |
|
108 |
|
109 asTime |
|
110 "return a Time object from the receiver. |
|
111 The returned time will only represent the timeOfDay - not the day, |
|
112 and does not include the milliseconds." |
|
113 |
|
114 |secondDelta| |
|
115 |
|
116 (osTime between:MinOSTime and:MaxOSTime) ifFalse:[ |
|
117 secondDelta := osTime // 1000. |
|
118 "/ we do not know about DST in the far future and in the long gone past. |
|
119 secondDelta := secondDelta rem:(24*3600) . |
|
120 ^ Epoch asTime addSeconds:secondDelta. |
|
121 ]. |
|
122 ^ self timeInfo asTime |
82 ! |
123 ! |
83 |
124 |
84 asUtcTimestamp |
125 asUtcTimestamp |
85 "I am an UtcTimestamp" |
126 "I am an UtcTimestamp" |
86 |
127 |