TZTimestamp.st
author Claus Gittinger <cg@exept.de>
Fri, 07 Nov 2014 13:12:01 +0100
changeset 16954 e13618117ebc
child 16966 7d549c75105f
permissions -rw-r--r--
initial checkin
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
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
Timestamp subclass:#TZTimestamp
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
	instanceVariableNames:'utcOffset'
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
	classVariableNames:''
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
	poolDictionaries:''
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
	category:'Magnitude-Time'
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
!
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
!TZTimestamp class methodsFor:'documentation'!
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
copyright
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 (c) 2014 by eXept Software AG
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
              All Rights Reserved
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
 This software is furnished under a license and may be used
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
 only in accordance with the terms of that license and with the
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
 inclusion of the above copyright notice.   This software may not
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
 be provided or otherwise made available to, or used by, any
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
 other person.  No title to or ownership of the software is
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
 hereby transferred.
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
"
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
!
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
documentation
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
"
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
    This class represents time values in milliSeconds starting some time in the past,
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
    which were created in another (explicit) timezone.
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
    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
    42
    so the time values can be compared easily.
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
    However, wehn printed, the original timezone information is taken into account.
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
    Also Note:
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
        On UNIX, osTime can only hold dates between 1970-01-01T00:00:00Z and 2038-01-19T00:00:00Z
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
        However, timestamp instances can now hold negative osTime values (which are timestamps
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
        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
    49
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
    [author:]
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
        Claus Gittinger
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
    [See also:]
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
        Timestamp UtcTimestamp Time Date
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
"
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
! !
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
!TZTimestamp methodsFor:'accessing'!
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
utcOffset
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
    "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
    62
     If daylight saving time applies to ourself, take that into account.
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
     Add utcOffset to convert from local time to UTC time.
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
     Subtract utcOffset to convert from UTC time to local time.
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
     If utcOffset is negative, the local timezone is east of Greenwich.
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
     If utcOffset is positive, the local timezone is west of Greenwich."
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
    ^  utcOffset
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
!
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
utcOffset:seconds
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
    "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
    75
     If daylight saving time applies to ourself, take that into account.
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
     Add utcOffset to convert from local time to UTC time.
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
     Subtract utcOffset to convert from UTC time to local time.
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
     If utcOffset is negative, the local timezone is east of Greenwich.
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
     If utcOffset is positive, the local timezone is west of Greenwich."
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
    utcOffset := seconds
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
!TZTimestamp class methodsFor:'documentation'!
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
version
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
    ^ '$Header: /cvs/stx/stx/libbasic/TZTimestamp.st,v 1.1 2014-11-07 12:12:01 cg Exp $'
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
!
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
version_CVS
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
    ^ '$Header: /cvs/stx/stx/libbasic/TZTimestamp.st,v 1.1 2014-11-07 12:12:01 cg Exp $'
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
! !
e13618117ebc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95