author | Claus Gittinger <cg@exept.de> |
Sat, 08 Nov 2014 01:20:53 +0100 | |
changeset 16997 | f0867a7f248b |
parent 16987 | 1c3e57adcf34 |
child 17028 | 7f4490e83429 |
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 |
||
14 |
Timestamp subclass:#UtcTimestamp |
|
15 |
instanceVariableNames:'' |
|
16 |
classVariableNames:'' |
|
17 |
poolDictionaries:'' |
|
18 |
category:'Magnitude-Time' |
|
19 |
! |
|
20 |
||
21 |
!UtcTimestamp class methodsFor:'documentation'! |
|
22 |
||
23 |
copyright |
|
24 |
" |
|
25 |
COPYRIGHT (c) 2011 by eXept Software AG |
|
26 |
All Rights Reserved |
|
27 |
||
28 |
This software is furnished under a license and may be used |
|
29 |
only in accordance with the terms of that license and with the |
|
30 |
inclusion of the above copyright notice. This software may not |
|
31 |
be provided or otherwise made available to, or used by, any |
|
32 |
other person. No title to or ownership of the software is |
|
33 |
hereby transferred. |
|
34 |
||
35 |
" |
|
36 |
! |
|
37 |
||
38 |
documentation |
|
39 |
" |
|
40 |
This is a Timestamp, that represents itself as UTC. |
|
13231 | 41 |
Internally it stores exactly the same value as Timestamp, |
15828 | 42 |
so the following expression is always true: |
13231 | 43 |
|
44 |
someTimestamp asUtcTimestamp = someTimestamp asLocalTimestamp |
|
45 |
||
46 |
But when printing, accessing hour, minute, ... and converting to Date and Time, |
|
47 |
it returns the values represented in the UTC zone instead of the local timezone. |
|
13227 | 48 |
|
49 |
[author:] |
|
50 |
Stefan Vogel (stefan@zwerg.nil.exept.de) |
|
51 |
||
52 |
[instance variables:] |
|
53 |
||
54 |
[class variables:] |
|
55 |
||
56 |
[see also:] |
|
13231 | 57 |
Time Date |
13227 | 58 |
|
59 |
" |
|
60 |
! ! |
|
61 |
||
62 |
!UtcTimestamp methodsFor:'accessing'! |
|
63 |
||
64 |
timeInfo |
|
16979 | 65 |
^ self utcTimeInfo |
13227 | 66 |
! |
67 |
||
68 |
timeZoneName |
|
16987 | 69 |
^ 'UTC' |
16969 | 70 |
! |
71 |
||
72 |
utcOffset |
|
73 |
^ 0 |
|
13227 | 74 |
! ! |
75 |
||
76 |
!UtcTimestamp methodsFor:'converting'! |
|
77 |
||
78 |
asLocalTimestamp |
|
13232
23a5fb2c645f
comment/format in: #asUtcTimestamp
Stefan Vogel <sv@exept.de>
parents:
13231
diff
changeset
|
79 |
"represent myself as a timestamp in the local timezone" |
13227 | 80 |
|
81 |
^ Timestamp fromOSTime:osTime |
|
82 |
! |
|
83 |
||
84 |
asUtcTimestamp |
|
13232
23a5fb2c645f
comment/format in: #asUtcTimestamp
Stefan Vogel <sv@exept.de>
parents:
13231
diff
changeset
|
85 |
"I am an UtcTimestamp" |
23a5fb2c645f
comment/format in: #asUtcTimestamp
Stefan Vogel <sv@exept.de>
parents:
13231
diff
changeset
|
86 |
|
13227 | 87 |
^ self |
88 |
! ! |
|
89 |
||
90 |
!UtcTimestamp methodsFor:'initialization'! |
|
91 |
||
16931 | 92 |
setOSTimeFromYear:y month:m day:d hour:h minute:min second:s millisecond:millis |
16987 | 93 |
"private: ask the operating system to compute the internal osTime (based on the epoch), |
94 |
given y,m,d and h,m,s in utc time" |
|
95 |
||
16997 | 96 |
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
|
97 |
|
600bc500741b
changed: #year:month:day:hour:minute:second:millisecond:
Claus Gittinger <cg@exept.de>
parents:
13232
diff
changeset
|
98 |
" |
16997 | 99 |
UtcTimestamp now |
100 |
Timestamp now |
|
101 |
Timestamp now asTZTimestamp |
|
102 |
Timestamp now asUtcTimestamp |
|
13794
600bc500741b
changed: #year:month:day:hour:minute:second:millisecond:
Claus Gittinger <cg@exept.de>
parents:
13232
diff
changeset
|
103 |
" |
600bc500741b
changed: #year:month:day:hour:minute:second:millisecond:
Claus Gittinger <cg@exept.de>
parents:
13232
diff
changeset
|
104 |
|
600bc500741b
changed: #year:month:day:hour:minute:second:millisecond:
Claus Gittinger <cg@exept.de>
parents:
13232
diff
changeset
|
105 |
"Modified (comment): / 13-10-2011 / 22:05:41 / cg" |
13227 | 106 |
! ! |
107 |
||
108 |
!UtcTimestamp methodsFor:'testing'! |
|
109 |
||
16969 | 110 |
isLocalTimestamp |
16987 | 111 |
"return true, if I am a local timestamp" |
112 |
||
16969 | 113 |
^ false |
114 |
! |
|
115 |
||
13227 | 116 |
isUtcTimestamp |
16987 | 117 |
"return true, if I am a utc timestamp" |
118 |
||
13227 | 119 |
^ true |
120 |
! ! |
|
121 |
||
122 |
!UtcTimestamp methodsFor:'visiting'! |
|
123 |
||
124 |
acceptVisitor:aVisitor with:aParameter |
|
16715 | 125 |
"dispatch for visitor pattern; send #visitUtcTimestamp:with: to aVisitor." |
126 |
||
13227 | 127 |
^ aVisitor visitUtcTimestamp:self with:aParameter |
128 |
! ! |
|
129 |
||
130 |
!UtcTimestamp class methodsFor:'documentation'! |
|
131 |
||
16987 | 132 |
version |
16997 | 133 |
^ '$Header: /cvs/stx/stx/libbasic/UtcTimestamp.st,v 1.11 2014-11-08 00:20:53 cg Exp $' |
16987 | 134 |
! |
135 |
||
13227 | 136 |
version_CVS |
16997 | 137 |
^ '$Header: /cvs/stx/stx/libbasic/UtcTimestamp.st,v 1.11 2014-11-08 00:20:53 cg Exp $' |
13227 | 138 |
! ! |
15828 | 139 |