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