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