author | Jan Vrany <jan.vrany@labware.com> |
Thu, 25 Mar 2021 20:30:03 +0000 | |
branch | jv |
changeset 25411 | 248600ba8fd9 |
parent 23547 | c69c97cec351 |
child 25423 | bcfde4da086a |
permissions | -rw-r--r-- |
13227 | 1 |
" |
2 |
COPYRIGHT (c) 2011 by eXept Software AG |
|
3 |
All Rights Reserved |
|
4 |
||
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
"{ Package: 'stx:libbasic' }" |
|
13 |
||
18452 | 14 |
"{ NameSpace: Smalltalk }" |
15 |
||
13227 | 16 |
Timestamp subclass:#UtcTimestamp |
17 |
instanceVariableNames:'' |
|
18 |
classVariableNames:'' |
|
19 |
poolDictionaries:'' |
|
20 |
category:'Magnitude-Time' |
|
21 |
! |
|
22 |
||
23 |
!UtcTimestamp class methodsFor:'documentation'! |
|
24 |
||
25 |
copyright |
|
26 |
" |
|
27 |
COPYRIGHT (c) 2011 by eXept Software AG |
|
28 |
All Rights Reserved |
|
29 |
||
30 |
This software is furnished under a license and may be used |
|
31 |
only in accordance with the terms of that license and with the |
|
32 |
inclusion of the above copyright notice. This software may not |
|
33 |
be provided or otherwise made available to, or used by, any |
|
34 |
other person. No title to or ownership of the software is |
|
35 |
hereby transferred. |
|
36 |
||
37 |
" |
|
38 |
! |
|
39 |
||
40 |
documentation |
|
41 |
" |
|
42 |
This is a Timestamp, that represents itself as UTC. |
|
13231 | 43 |
Internally it stores exactly the same value as Timestamp, |
15828 | 44 |
so the following expression is always true: |
13231 | 45 |
|
46 |
someTimestamp asUtcTimestamp = someTimestamp asLocalTimestamp |
|
47 |
||
48 |
But when printing, accessing hour, minute, ... and converting to Date and Time, |
|
49 |
it returns the values represented in the UTC zone instead of the local timezone. |
|
17130 | 50 |
Be aware that this may lead to interesting results; for example when converting a timestamp |
51 |
to a date, you may get a different date from an UTCTimestamp and a local timestamp. |
|
13227 | 52 |
|
53 |
[author:] |
|
54 |
Stefan Vogel (stefan@zwerg.nil.exept.de) |
|
55 |
||
56 |
[instance variables:] |
|
57 |
||
58 |
[class variables:] |
|
59 |
||
60 |
[see also:] |
|
13231 | 61 |
Time Date |
13227 | 62 |
|
63 |
" |
|
64 |
! ! |
|
65 |
||
66 |
!UtcTimestamp methodsFor:'accessing'! |
|
67 |
||
68 |
timeInfo |
|
16979 | 69 |
^ self utcTimeInfo |
13227 | 70 |
! |
71 |
||
72 |
timeZoneName |
|
16987 | 73 |
^ 'UTC' |
16969 | 74 |
! |
75 |
||
76 |
utcOffset |
|
18452 | 77 |
"I am an UTC timestamp, so there is no offset" |
78 |
||
16969 | 79 |
^ 0 |
17032 | 80 |
! |
81 |
||
82 |
utcOffsetWithoutDst |
|
83 |
^ 0 |
|
13227 | 84 |
! ! |
85 |
||
86 |
!UtcTimestamp methodsFor:'converting'! |
|
87 |
||
88 |
asLocalTimestamp |
|
13232
23a5fb2c645f
comment/format in: #asUtcTimestamp
Stefan Vogel <sv@exept.de>
parents:
13231
diff
changeset
|
89 |
"represent myself as a timestamp in the local timezone" |
13227 | 90 |
|
91 |
^ Timestamp fromOSTime:osTime |
|
92 |
! |
|
93 |
||
94 |
asUtcTimestamp |
|
13232
23a5fb2c645f
comment/format in: #asUtcTimestamp
Stefan Vogel <sv@exept.de>
parents:
13231
diff
changeset
|
95 |
"I am an UtcTimestamp" |
23a5fb2c645f
comment/format in: #asUtcTimestamp
Stefan Vogel <sv@exept.de>
parents:
13231
diff
changeset
|
96 |
|
13227 | 97 |
^ self |
98 |
! ! |
|
99 |
||
100 |
!UtcTimestamp methodsFor:'initialization'! |
|
101 |
||
16931 | 102 |
setOSTimeFromYear:y month:m day:d hour:h minute:min second:s millisecond:millis |
16987 | 103 |
"private: ask the operating system to compute the internal osTime (based on the epoch), |
104 |
given y,m,d and h,m,s in utc time" |
|
105 |
||
16997 | 106 |
self setOSTimeFromUTCYear:y month:m day:d hour:h minute:min second:s millisecond:millis |
13794
600bc500741b
changed: #year:month:day:hour:minute:second:millisecond:
Claus Gittinger <cg@exept.de>
parents:
13232
diff
changeset
|
107 |
|
600bc500741b
changed: #year:month:day:hour:minute:second:millisecond:
Claus Gittinger <cg@exept.de>
parents:
13232
diff
changeset
|
108 |
" |
16997 | 109 |
UtcTimestamp now |
110 |
Timestamp now |
|
111 |
Timestamp now asTZTimestamp |
|
112 |
Timestamp now asUtcTimestamp |
|
13794
600bc500741b
changed: #year:month:day:hour:minute:second:millisecond:
Claus Gittinger <cg@exept.de>
parents:
13232
diff
changeset
|
113 |
" |
600bc500741b
changed: #year:month:day:hour:minute:second:millisecond:
Claus Gittinger <cg@exept.de>
parents:
13232
diff
changeset
|
114 |
|
600bc500741b
changed: #year:month:day:hour:minute:second:millisecond:
Claus Gittinger <cg@exept.de>
parents:
13232
diff
changeset
|
115 |
"Modified (comment): / 13-10-2011 / 22:05:41 / cg" |
13227 | 116 |
! ! |
117 |
||
17051 | 118 |
!UtcTimestamp methodsFor:'private'! |
119 |
||
120 |
storeStringClass |
|
121 |
^ Timestamp |
|
122 |
! ! |
|
123 |
||
13227 | 124 |
!UtcTimestamp methodsFor:'testing'! |
125 |
||
16969 | 126 |
isLocalTimestamp |
16987 | 127 |
"return true, if I am a local timestamp" |
128 |
||
16969 | 129 |
^ false |
130 |
! |
|
131 |
||
13227 | 132 |
isUtcTimestamp |
16987 | 133 |
"return true, if I am a utc timestamp" |
134 |
||
13227 | 135 |
^ true |
136 |
! ! |
|
137 |
||
138 |
!UtcTimestamp methodsFor:'visiting'! |
|
139 |
||
140 |
acceptVisitor:aVisitor with:aParameter |
|
16715 | 141 |
"dispatch for visitor pattern; send #visitUtcTimestamp:with: to aVisitor." |
142 |
||
13227 | 143 |
^ aVisitor visitUtcTimestamp:self with:aParameter |
144 |
! ! |
|
145 |
||
146 |
!UtcTimestamp class methodsFor:'documentation'! |
|
147 |
||
16987 | 148 |
version |
18452 | 149 |
^ '$Header: /cvs/stx/stx/libbasic/UtcTimestamp.st,v 1.16 2015-06-06 12:42:18 cg Exp $' |
16987 | 150 |
! |
151 |
||
13227 | 152 |
version_CVS |
18452 | 153 |
^ '$Header: /cvs/stx/stx/libbasic/UtcTimestamp.st,v 1.16 2015-06-06 12:42:18 cg Exp $' |
13227 | 154 |
! ! |
15828 | 155 |