eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'TZTimestamp':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: TZTimestamp


Inheritance:

   Object
   |
   +--Magnitude
      |
      +--AbstractTime
         |
         +--Timestamp
            |
            +--TZTimestamp

Package:
stx:libbasic
Category:
Magnitude-Time
Version:
rev: 1.17 date: 2019/05/26 10:55:41
user: cg
file: TZTimestamp.st directory: libbasic
module: stx stc-classLibrary: libbasic
Author:
Claus Gittinger

Description:


This class represents time values in milliSeconds starting some time in the past,
which were created in another (explicit) timezone.
Internally, they keep the milliseconds based on UTC time (just like the other timestamps),
so the time values can be compared easily.
However, when printed, the original timezone information is taken into account.

Also Note:
    On UNIX, osTime can only hold dates between 1970-01-01T00:00:00Z and 2038-01-19T00:00:00Z
    However, timestamp instances can hold negative osTime values (which are timestamps
    before 1.1.1970 and greater than 4294967295 (2^32-1) for timestamps after 2038-01-19.

[example:]
  the current time as local time:
    Transcript showCR:Timestamp now

  the current time as utc time:       
    Transcript showCR:UtcTimestamp now.
  same:
    Transcript showCR:Timestamp now asUtcTimestamp.

  the current time in NewYork:         
    Transcript showCR:( Timestamp now asTZTimestamp:(Timestamp utcOffsetFrom:'EST') ) 
  same
    Transcript showCR:( Timestamp now asTZTimestampInZone:'EST' )
  same
    Transcript showCR:( Timestamp now asTZTimestamp:(5*3600) ) 

  what is the current time in Berlin:
    Transcript showCR:( Timestamp now asTZTimestampInZone:'MEZ' ) 

  and the date:
    Transcript showCR:( Timestamp now asTZTimestampInZone:'MEZ' ) asDate
  and the date in Tokio:
    Transcript showCR:( Timestamp now asTZTimestampInZone:'JST' ) asDate
  and the date in Hawai:
    Transcript showCR:( Timestamp now asTZTimestampInZone:'HAST' ) asDate
  and the date in NewYork:
    Transcript showCR:( Timestamp now asTZTimestampInZone:'EST' ) asDate


Related information:

    Timestamp
    UtcTimestamp
    Time
    Date

Class protocol:

instance creation
o  fromDate: aDate andTime: aTime utcOffset: utcOffsetSeconds
return an instance of the receiver,
initialized from a time and a date object.
Both date and time are assumed to be the utcOffset's local time.
See also `Timestamp now' and other protocol inherited
from my superclass.

usage example(s):

     Timestamp fromDate:(Date today) andTime:(Time now)
     Timestamp fromDate:(Date today) andTime:(Time nowWithMilliseconds)

     TZTimestamp fromDate:(Date today) andTime:(Time now) utcOffset:3600

     Timestamp fromDate:(Date today plusDays:1) andTime:(Time now)
     Timestamp now


Instance protocol:

accessing
o  isLocalTimestamp
return true, if I am a local timestamp (i.e. with no TZ info)

o  timeInfo
fake it. Convert to utc, ask OS for the info, then convert back.
This is returns wrong info for weekday and we have to compensate again.
Also, it (currently) only works for timestamps after the epoch

o  utcOffset
return the difference between UTC (Greenwich Mean Time) and the local time in seconds.
If daylight saving time applies to ourself, take that into account.

Add utcOffset to convert from local time to UTC time.
Subtract utcOffset to convert from UTC time to local time.

If utcOffset is negative, the local timezone is east of Greenwich.
If utcOffset is positive, the local timezone is west of Greenwich.

o  utcOffset: secondsOrTimeDuration
set the difference between UTC (Greenwich Mean Time) and the local time in seconds.
If daylight saving time applies to ourself, take that into account.

Add utcOffset to convert from local time to UTC time.
Subtract utcOffset to convert from UTC time to local time.

If utcOffset is negative, the local timezone is east of Greenwich.
If utcOffset is positive, the local timezone is west of Greenwich.

converting
o  asLocalTimestamp
return a local timestamp, representing the same time as the receiver

o  asTZTimestamp: utcOffsetArg
return a timestamp in a given timezone, representing the same time as the receiver

usage example(s):

what is the time now in NewYork?
     Timestamp now asTZTimestamp:(Timestamp utcOffsetFrom:'EST') 

     what is the time now in Stuttgart?
     Timestamp now asTZTimestamp:(Timestamp utcOffsetFrom:'MEZ')  

private
o  speciesNew

o  storeStringClass

testing
o  isTZTimestamp
return true, if I am a timestamp with TZ info



ST/X 7.2.0.0; WebServer 1.670 at bd0aa1f87cdd.unknown:8081; Thu, 25 Apr 2024 14:23:44 GMT