TZTimestamp.st
author Claus Gittinger <cg@exept.de>
Tue, 02 Apr 2019 10:50:28 +0200
branchjv
changeset 24091 691c182c3105
parent 23547 c69c97cec351
child 25423 bcfde4da086a
permissions -rw-r--r--
#BUGFIX by cg class: CharacterArray changed: #, #asDenseUnicodeString (grafted from ba4c42171801ea3a46aea31504a621256655feae)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
16954
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
"
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
 COPYRIGHT (c) 2014 by eXept Software AG
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
              All Rights Reserved
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
 This software is furnished under a license and may be used
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
 hereby transferred.
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
"
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
"{ Package: 'stx:libbasic' }"
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
17423
f8f1483630b2 class: TZTimestamp
Stefan Vogel <sv@exept.de>
parents: 17134
diff changeset
    14
"{ NameSpace: Smalltalk }"
f8f1483630b2 class: TZTimestamp
Stefan Vogel <sv@exept.de>
parents: 17134
diff changeset
    15
16954
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
Timestamp subclass:#TZTimestamp
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
	instanceVariableNames:'utcOffset'
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
	classVariableNames:''
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
	poolDictionaries:''
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
	category:'Magnitude-Time'
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
!
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
!TZTimestamp class methodsFor:'documentation'!
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
copyright
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
"
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
 COPYRIGHT (c) 2014 by eXept Software AG
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
              All Rights Reserved
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
 This software is furnished under a license and may be used
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
 only in accordance with the terms of that license and with the
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
 inclusion of the above copyright notice.   This software may not
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
 be provided or otherwise made available to, or used by, any
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
 other person.  No title to or ownership of the software is
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
 hereby transferred.
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
"
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
!
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
documentation
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
"
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
    This class represents time values in milliSeconds starting some time in the past,
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
    which were created in another (explicit) timezone.
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
    Internally, they keep the milliseconds based on UTC time (just like the other timestamps),
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
    so the time values can be compared easily.
17134
161e73014492 class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 17103
diff changeset
    45
    However, when printed, the original timezone information is taken into account.
16954
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
    Also Note:
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
        On UNIX, osTime can only hold dates between 1970-01-01T00:00:00Z and 2038-01-19T00:00:00Z
17134
161e73014492 class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 17103
diff changeset
    49
        However, timestamp instances can hold negative osTime values (which are timestamps
16954
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
        before 1.1.1970 and greater than 4294967295 (2^32-1) for timestamps after 2038-01-19.
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
16966
7d549c75105f class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 16954
diff changeset
    52
    [example:]
7d549c75105f class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 16954
diff changeset
    53
      the current time as local time:
7d549c75105f class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 16954
diff changeset
    54
        Transcript showCR:Timestamp now
7d549c75105f class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 16954
diff changeset
    55
7d549c75105f class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 16954
diff changeset
    56
      the current time as utc time:       
17134
161e73014492 class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 17103
diff changeset
    57
        Transcript showCR:UtcTimestamp now.
16966
7d549c75105f class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 16954
diff changeset
    58
      same:
17134
161e73014492 class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 17103
diff changeset
    59
        Transcript showCR:Timestamp now asUtcTimestamp.
16966
7d549c75105f class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 16954
diff changeset
    60
7d549c75105f class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 16954
diff changeset
    61
      the current time in NewYork:         
17134
161e73014492 class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 17103
diff changeset
    62
        Transcript showCR:( Timestamp now asTZTimestamp:(Timestamp utcOffsetFrom:'EST') ) 
161e73014492 class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 17103
diff changeset
    63
      same
161e73014492 class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 17103
diff changeset
    64
        Transcript showCR:( Timestamp now asTZTimestampInZone:'EST' )
161e73014492 class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 17103
diff changeset
    65
      same
161e73014492 class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 17103
diff changeset
    66
        Transcript showCR:( Timestamp now asTZTimestamp:(5*3600) ) 
161e73014492 class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 17103
diff changeset
    67
161e73014492 class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 17103
diff changeset
    68
      what is the current time in Berlin:
161e73014492 class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 17103
diff changeset
    69
        Transcript showCR:( Timestamp now asTZTimestampInZone:'MEZ' ) 
161e73014492 class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 17103
diff changeset
    70
      and the date:
161e73014492 class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 17103
diff changeset
    71
        Transcript showCR:( Timestamp now asTZTimestampInZone:'MEZ' ) asDate
161e73014492 class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 17103
diff changeset
    72
      and the date in Tokio:
161e73014492 class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 17103
diff changeset
    73
        Transcript showCR:( Timestamp now asTZTimestampInZone:'JST' ) asDate
161e73014492 class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 17103
diff changeset
    74
      and the date in Hawai:
161e73014492 class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 17103
diff changeset
    75
        Transcript showCR:( Timestamp now asTZTimestampInZone:'HAST' ) asDate
16966
7d549c75105f class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 16954
diff changeset
    76
16954
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
    [author:]
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
        Claus Gittinger
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
    [See also:]
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
        Timestamp UtcTimestamp Time Date
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
"
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
! !
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
17423
f8f1483630b2 class: TZTimestamp
Stefan Vogel <sv@exept.de>
parents: 17134
diff changeset
    85
!TZTimestamp class methodsFor:'instance creation'!
f8f1483630b2 class: TZTimestamp
Stefan Vogel <sv@exept.de>
parents: 17134
diff changeset
    86
f8f1483630b2 class: TZTimestamp
Stefan Vogel <sv@exept.de>
parents: 17134
diff changeset
    87
fromDate:aDate andTime:aTime utcOffset:utcOffsetSeconds
f8f1483630b2 class: TZTimestamp
Stefan Vogel <sv@exept.de>
parents: 17134
diff changeset
    88
    "return an instance of the receiver, initialized from a time and a date
f8f1483630b2 class: TZTimestamp
Stefan Vogel <sv@exept.de>
parents: 17134
diff changeset
    89
     object.
f8f1483630b2 class: TZTimestamp
Stefan Vogel <sv@exept.de>
parents: 17134
diff changeset
    90
     See also `Timestamp now' and other protocol inherited
f8f1483630b2 class: TZTimestamp
Stefan Vogel <sv@exept.de>
parents: 17134
diff changeset
    91
     from my superclass."
f8f1483630b2 class: TZTimestamp
Stefan Vogel <sv@exept.de>
parents: 17134
diff changeset
    92
f8f1483630b2 class: TZTimestamp
Stefan Vogel <sv@exept.de>
parents: 17134
diff changeset
    93
    ^ (self
f8f1483630b2 class: TZTimestamp
Stefan Vogel <sv@exept.de>
parents: 17134
diff changeset
    94
        UTCYear:aDate year
f8f1483630b2 class: TZTimestamp
Stefan Vogel <sv@exept.de>
parents: 17134
diff changeset
    95
        month:aDate month
f8f1483630b2 class: TZTimestamp
Stefan Vogel <sv@exept.de>
parents: 17134
diff changeset
    96
        day:aDate day
f8f1483630b2 class: TZTimestamp
Stefan Vogel <sv@exept.de>
parents: 17134
diff changeset
    97
        hour:aTime hours
f8f1483630b2 class: TZTimestamp
Stefan Vogel <sv@exept.de>
parents: 17134
diff changeset
    98
        minute:aTime minutes
f8f1483630b2 class: TZTimestamp
Stefan Vogel <sv@exept.de>
parents: 17134
diff changeset
    99
        second:aTime seconds + utcOffsetSeconds
f8f1483630b2 class: TZTimestamp
Stefan Vogel <sv@exept.de>
parents: 17134
diff changeset
   100
        millisecond:aTime milliseconds)
f8f1483630b2 class: TZTimestamp
Stefan Vogel <sv@exept.de>
parents: 17134
diff changeset
   101
            utcOffset:utcOffsetSeconds
f8f1483630b2 class: TZTimestamp
Stefan Vogel <sv@exept.de>
parents: 17134
diff changeset
   102
f8f1483630b2 class: TZTimestamp
Stefan Vogel <sv@exept.de>
parents: 17134
diff changeset
   103
    "
f8f1483630b2 class: TZTimestamp
Stefan Vogel <sv@exept.de>
parents: 17134
diff changeset
   104
     Timestamp fromDate:(Date today) andTime:(Time now)
f8f1483630b2 class: TZTimestamp
Stefan Vogel <sv@exept.de>
parents: 17134
diff changeset
   105
     Timestamp fromDate:(Date today) andTime:(Time nowWithMilliseconds)
f8f1483630b2 class: TZTimestamp
Stefan Vogel <sv@exept.de>
parents: 17134
diff changeset
   106
f8f1483630b2 class: TZTimestamp
Stefan Vogel <sv@exept.de>
parents: 17134
diff changeset
   107
     Timestamp fromDate:(Date today plusDays:1) andTime:(Time now)
f8f1483630b2 class: TZTimestamp
Stefan Vogel <sv@exept.de>
parents: 17134
diff changeset
   108
     Timestamp now
f8f1483630b2 class: TZTimestamp
Stefan Vogel <sv@exept.de>
parents: 17134
diff changeset
   109
    "
f8f1483630b2 class: TZTimestamp
Stefan Vogel <sv@exept.de>
parents: 17134
diff changeset
   110
! !
f8f1483630b2 class: TZTimestamp
Stefan Vogel <sv@exept.de>
parents: 17134
diff changeset
   111
16954
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
!TZTimestamp methodsFor:'accessing'!
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
16966
7d549c75105f class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 16954
diff changeset
   114
isLocalTimestamp
7d549c75105f class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 16954
diff changeset
   115
    ^ false
7d549c75105f class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 16954
diff changeset
   116
!
7d549c75105f class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 16954
diff changeset
   117
7d549c75105f class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 16954
diff changeset
   118
timeInfo
16984
46430aef9bec class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 16980
diff changeset
   119
    "fake it. Convert to utc, ask OS for the info, then convert back.
46430aef9bec class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 16980
diff changeset
   120
     This is returns wrong info for weekday and we have to compensate again.
46430aef9bec class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 16980
diff changeset
   121
     Also, it (currently) only works for timestamps after the epoch"
16966
7d549c75105f class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 16954
diff changeset
   122
7d549c75105f class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 16954
diff changeset
   123
    |ti|
7d549c75105f class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 16954
diff changeset
   124
7d549c75105f class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 16954
diff changeset
   125
    "/ utcOffset negative: east of GMT
18453
71812472e0a5 class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 18450
diff changeset
   126
    ti := OperatingSystem computeUTCTimeAndDateFrom:(osTime - ((utcOffset ? 0) * 1000)).
71812472e0a5 class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 18450
diff changeset
   127
    ti utcOffset:(utcOffset ? 0).
16966
7d549c75105f class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 16954
diff changeset
   128
    ^ ti
7d549c75105f class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 16954
diff changeset
   129
!
7d549c75105f class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 16954
diff changeset
   130
16954
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
utcOffset
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
    "return the difference between UTC (Greenwich Mean Time) and the local time in seconds.
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
     If daylight saving time applies to ourself, take that into account.
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
     Add utcOffset to convert from local time to UTC time.
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
     Subtract utcOffset to convert from UTC time to local time.
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
     If utcOffset is negative, the local timezone is east of Greenwich.
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
     If utcOffset is positive, the local timezone is west of Greenwich."
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
18453
71812472e0a5 class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 18450
diff changeset
   141
    ^ utcOffset ? 0
16954
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
!
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   143
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   144
utcOffset:seconds
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   145
    "set the difference between UTC (Greenwich Mean Time) and the local time in seconds.
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   146
     If daylight saving time applies to ourself, take that into account.
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   147
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
     Add utcOffset to convert from local time to UTC time.
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
     Subtract utcOffset to convert from UTC time to local time.
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   150
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   151
     If utcOffset is negative, the local timezone is east of Greenwich.
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   152
     If utcOffset is positive, the local timezone is west of Greenwich."
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   153
17103
d390437c201f class: TZTimestamp
sr
parents: 17050
diff changeset
   154
    utcOffset := seconds asInteger.
d390437c201f class: TZTimestamp
sr
parents: 17050
diff changeset
   155
d390437c201f class: TZTimestamp
sr
parents: 17050
diff changeset
   156
    "Modified: / 20-11-2014 / 13:05:48 / sr"
16954
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   157
! !
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   158
16966
7d549c75105f class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 16954
diff changeset
   159
!TZTimestamp methodsFor:'converting'!
7d549c75105f class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 16954
diff changeset
   160
7d549c75105f class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 16954
diff changeset
   161
asLocalTimestamp
7d549c75105f class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 16954
diff changeset
   162
    "return a local timestamp, representing the same time as the receiver"
7d549c75105f class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 16954
diff changeset
   163
7d549c75105f class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 16954
diff changeset
   164
    ^ Timestamp fromOSTime:osTime.
7d549c75105f class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 16954
diff changeset
   165
!
7d549c75105f class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 16954
diff changeset
   166
7d549c75105f class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 16954
diff changeset
   167
asTZTimestamp:utcOffsetArg
7d549c75105f class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 16954
diff changeset
   168
    "return a timestamp in a given timezone, representing the same time as the receiver"
7d549c75105f class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 16954
diff changeset
   169
7d549c75105f class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 16954
diff changeset
   170
    utcOffset = utcOffsetArg ifTrue:[
7d549c75105f class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 16954
diff changeset
   171
        ^ self.
7d549c75105f class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 16954
diff changeset
   172
    ].
7d549c75105f class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 16954
diff changeset
   173
    ^ super asTZTimestamp:utcOffsetArg
16976
34cb1703d013 class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 16966
diff changeset
   174
34cb1703d013 class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 16966
diff changeset
   175
    "what is the time now in NewYork?
34cb1703d013 class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 16966
diff changeset
   176
     Timestamp now asTZTimestamp:(Timestamp utcOffsetFrom:'EST') 
34cb1703d013 class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 16966
diff changeset
   177
34cb1703d013 class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 16966
diff changeset
   178
     what is the time now in Stuttgart?
34cb1703d013 class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 16966
diff changeset
   179
     Timestamp now asTZTimestamp:(Timestamp utcOffsetFrom:'MEZ')  
34cb1703d013 class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 16966
diff changeset
   180
    "
16966
7d549c75105f class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 16954
diff changeset
   181
! !
7d549c75105f class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 16954
diff changeset
   182
17019
15fb22ffb5fe class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 16984
diff changeset
   183
!TZTimestamp methodsFor:'private'!
15fb22ffb5fe class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 16984
diff changeset
   184
15fb22ffb5fe class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 16984
diff changeset
   185
speciesNew
15fb22ffb5fe class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 16984
diff changeset
   186
    ^ self species basicNew 
18450
77835f6f73ad class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 17423
diff changeset
   187
        utcOffset:(utcOffset ? 0);
17019
15fb22ffb5fe class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 16984
diff changeset
   188
        yourself
17050
f421040c58ae class: TZTimestamp
ca
parents: 17019
diff changeset
   189
!
f421040c58ae class: TZTimestamp
ca
parents: 17019
diff changeset
   190
f421040c58ae class: TZTimestamp
ca
parents: 17019
diff changeset
   191
storeStringClass
f421040c58ae class: TZTimestamp
ca
parents: 17019
diff changeset
   192
    ^ Timestamp
17019
15fb22ffb5fe class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 16984
diff changeset
   193
! !
15fb22ffb5fe class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 16984
diff changeset
   194
16954
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   195
!TZTimestamp class methodsFor:'documentation'!
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   196
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   197
version
18453
71812472e0a5 class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 18450
diff changeset
   198
    ^ '$Header: /cvs/stx/stx/libbasic/TZTimestamp.st,v 1.12 2015-06-06 12:42:27 cg Exp $'
16954
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   199
!
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   200
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   201
version_CVS
18453
71812472e0a5 class: TZTimestamp
Claus Gittinger <cg@exept.de>
parents: 18450
diff changeset
   202
    ^ '$Header: /cvs/stx/stx/libbasic/TZTimestamp.st,v 1.12 2015-06-06 12:42:27 cg Exp $'
16954
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   203
! !
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   204