author | Stefan Vogel <sv@exept.de> |
Mon, 25 Nov 2013 15:50:54 +0100 | |
changeset 15828 | 1564a3c784fa |
parent 13794 | 600bc500741b |
child 16715 | 5528600b6497 |
child 18112 | 0d7ac9096619 |
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 |
|
65 |
^ OperatingSystem computeUTCTimeAndDateFrom:osTime |
|
66 |
! |
|
67 |
||
68 |
timeZoneName |
|
69 |
^ #utc |
|
70 |
! ! |
|
71 |
||
72 |
!UtcTimestamp methodsFor:'converting'! |
|
73 |
||
74 |
asLocalTimestamp |
|
13232
23a5fb2c645f
comment/format in: #asUtcTimestamp
Stefan Vogel <sv@exept.de>
parents:
13231
diff
changeset
|
75 |
"represent myself as a timestamp in the local timezone" |
13227 | 76 |
|
77 |
^ Timestamp fromOSTime:osTime |
|
78 |
! |
|
79 |
||
80 |
asUtcTimestamp |
|
13232
23a5fb2c645f
comment/format in: #asUtcTimestamp
Stefan Vogel <sv@exept.de>
parents:
13231
diff
changeset
|
81 |
"I am an UtcTimestamp" |
23a5fb2c645f
comment/format in: #asUtcTimestamp
Stefan Vogel <sv@exept.de>
parents:
13231
diff
changeset
|
82 |
|
13227 | 83 |
^ self |
84 |
! ! |
|
85 |
||
86 |
!UtcTimestamp methodsFor:'initialization'! |
|
87 |
||
88 |
year:y month:m day:d hour:h minute:min second:s millisecond:millis |
|
89 |
osTime := OperatingSystem |
|
90 |
computeOSTimeFromUTCYear:y |
|
91 |
month:m |
|
92 |
day:d |
|
93 |
hour:h |
|
94 |
minute:min |
|
95 |
second:s |
|
96 |
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 |
" |
600bc500741b
changed: #year:month:day:hour:minute:second:millisecond:
Claus Gittinger <cg@exept.de>
parents:
13232
diff
changeset
|
99 |
UtcTimestamp now |
600bc500741b
changed: #year:month:day:hour:minute:second:millisecond:
Claus Gittinger <cg@exept.de>
parents:
13232
diff
changeset
|
100 |
Timestamp now |
600bc500741b
changed: #year:month:day:hour:minute:second:millisecond:
Claus Gittinger <cg@exept.de>
parents:
13232
diff
changeset
|
101 |
" |
600bc500741b
changed: #year:month:day:hour:minute:second:millisecond:
Claus Gittinger <cg@exept.de>
parents:
13232
diff
changeset
|
102 |
|
600bc500741b
changed: #year:month:day:hour:minute:second:millisecond:
Claus Gittinger <cg@exept.de>
parents:
13232
diff
changeset
|
103 |
"Modified (comment): / 13-10-2011 / 22:05:41 / cg" |
13227 | 104 |
! ! |
105 |
||
106 |
!UtcTimestamp methodsFor:'testing'! |
|
107 |
||
108 |
isUtcTimestamp |
|
109 |
^ true |
|
110 |
! ! |
|
111 |
||
112 |
!UtcTimestamp methodsFor:'visiting'! |
|
113 |
||
114 |
acceptVisitor:aVisitor with:aParameter |
|
115 |
^ aVisitor visitUtcTimestamp:self with:aParameter |
|
116 |
! ! |
|
117 |
||
118 |
!UtcTimestamp class methodsFor:'documentation'! |
|
119 |
||
120 |
version_CVS |
|
15828 | 121 |
^ '$Header: /cvs/stx/stx/libbasic/UtcTimestamp.st,v 1.5 2013-11-25 14:50:54 stefan Exp $' |
13227 | 122 |
! ! |
15828 | 123 |