Timestamp.st
author Claus Gittinger <cg@exept.de>
Wed, 25 Oct 2000 11:18:46 +0200
changeset 5677 52bd6bf1775f
parent 5656 dbc52ea02716
child 5678 5e1e70d18067
permissions -rw-r--r--
us/non-us format reading ($/ as separator: us-format)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
30
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
     1
"
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
     2
 COPYRIGHT (c) 1989 by Claus Gittinger
154
d4236ec280a6 *** empty log message ***
claus
parents: 92
diff changeset
     3
	      All Rights Reserved
30
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
     4
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
    11
"
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
    12
5376
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
    13
"{ Package: 'stx:libbasic' }"
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
    14
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
    15
AbstractTime subclass:#AbsoluteTime
795
ff477bad0f2d fix setSeconds:
Stefan Vogel <sv@exept.de>
parents: 699
diff changeset
    16
	instanceVariableNames:'osTime'
ff477bad0f2d fix setSeconds:
Stefan Vogel <sv@exept.de>
parents: 699
diff changeset
    17
	classVariableNames:''
ff477bad0f2d fix setSeconds:
Stefan Vogel <sv@exept.de>
parents: 699
diff changeset
    18
	poolDictionaries:''
ff477bad0f2d fix setSeconds:
Stefan Vogel <sv@exept.de>
parents: 699
diff changeset
    19
	category:'Magnitude-General'
30
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
    20
!
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
    21
2311
88b035dd471a New Method: #secondsSince1970.
Stefan Vogel <sv@exept.de>
parents: 1701
diff changeset
    22
!AbsoluteTime class methodsFor:'documentation'!
30
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
    23
82
0147b4f725ae *** empty log message ***
claus
parents: 77
diff changeset
    24
copyright
0147b4f725ae *** empty log message ***
claus
parents: 77
diff changeset
    25
"
0147b4f725ae *** empty log message ***
claus
parents: 77
diff changeset
    26
 COPYRIGHT (c) 1989 by Claus Gittinger
154
d4236ec280a6 *** empty log message ***
claus
parents: 92
diff changeset
    27
	      All Rights Reserved
82
0147b4f725ae *** empty log message ***
claus
parents: 77
diff changeset
    28
0147b4f725ae *** empty log message ***
claus
parents: 77
diff changeset
    29
 This software is furnished under a license and may be used
0147b4f725ae *** empty log message ***
claus
parents: 77
diff changeset
    30
 only in accordance with the terms of that license and with the
0147b4f725ae *** empty log message ***
claus
parents: 77
diff changeset
    31
 inclusion of the above copyright notice.   This software may not
0147b4f725ae *** empty log message ***
claus
parents: 77
diff changeset
    32
 be provided or otherwise made available to, or used by, any
0147b4f725ae *** empty log message ***
claus
parents: 77
diff changeset
    33
 other person.  No title to or ownership of the software is
0147b4f725ae *** empty log message ***
claus
parents: 77
diff changeset
    34
 hereby transferred.
0147b4f725ae *** empty log message ***
claus
parents: 77
diff changeset
    35
"
0147b4f725ae *** empty log message ***
claus
parents: 77
diff changeset
    36
!
0147b4f725ae *** empty log message ***
claus
parents: 77
diff changeset
    37
30
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
    38
documentation
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
    39
"
1669
4951596746f7 comments & code cleanup
Claus Gittinger <cg@exept.de>
parents: 1521
diff changeset
    40
    This class represents absolute time values in milliSeconds starting some
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
    41
    time in the past. 
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
    42
    (typically, from 1st. Jan 1970, as used in the Unix operating system,
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
    43
     but other systems may bias the time differently.
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
    44
     Actually, the implementation does not depend or even know which time/date 
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
    45
     the OperatingSystem bases its time upon - it is simply keeping the value(s)
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
    46
     as return from the OS.
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
    47
     For conversion, these values are given back to the OS, which will know
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
    48
     how to convert these times.
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
    49
     This has the advantage, that time-stamps on files (such as last-access-
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
    50
     time or last-modifiaction-time) can be handled transparent to other
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
    51
     times - especially comparisons).
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
    52
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
    53
    You should not interpret the osTime instance variable directly, instead
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
    54
    (if at all), as the OS to convert.
30
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
    55
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
    56
    Its implementation is not the same as in ST-80 
1669
4951596746f7 comments & code cleanup
Claus Gittinger <cg@exept.de>
parents: 1521
diff changeset
    57
    (which represents Time as seconds from 1. Jan 1901.)
30
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
    58
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
    59
    This class should not be confused with Time (which only represents the
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
    60
    time within one day). 
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
    61
    Time instances cannot be used to compare times across midnight; 
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
    62
    instances of AbsoluteTime can.
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
    63
3479
9ca6229713f4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3122
diff changeset
    64
    Notice: this class is aliased as Timestamp for ST-80 compatibility.
9ca6229713f4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3122
diff changeset
    65
1306
c0189edbd96c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1282
diff changeset
    66
    [author:]
4679
957773d921a8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4378
diff changeset
    67
	Claus Gittinger
1306
c0189edbd96c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1282
diff changeset
    68
1282
3f5eda57c516 commentary
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
    69
    [See also:]
4679
957773d921a8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4378
diff changeset
    70
	Time Date
957773d921a8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4378
diff changeset
    71
	Delay ProcessorScheduler
30
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
    72
"
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
    73
! !
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
    74
2311
88b035dd471a New Method: #secondsSince1970.
Stefan Vogel <sv@exept.de>
parents: 1701
diff changeset
    75
!AbsoluteTime class methodsFor:'instance creation'!
30
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
    76
4378
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
    77
UTCYear:y month:m day:d hour:h minute:min second:s millisecond:millis
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
    78
    "return an instance of the receiver, given individual components.
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
    79
     See also `AbsoluteTime now' and other protocol inherited
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
    80
     from my superclass."
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
    81
423
claus
parents: 392
diff changeset
    82
    ^ self basicNew 
4679
957773d921a8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4378
diff changeset
    83
	fromOSTime:(OperatingSystem 
957773d921a8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4378
diff changeset
    84
			computeOSTimeFromUTCYear:y month:m day:d 
957773d921a8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4378
diff changeset
    85
					 hour:h minute:min second:s
957773d921a8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4378
diff changeset
    86
					 millisecond:millis)
30
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
    87
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
    88
    "
4378
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
    89
     AbsoluteTime UTCYear:1970 month:1 day:1 hour:1 minute:0 second:0 millisecond:0
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
    90
     AbsoluteTime UTCYear:1991 month:1 day:2 hour:12 minute:30 second:0 millisecond:0
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
    91
     AbsoluteTime UTCYear:1991 month:1 day:2 hour:12 minute:30 second:0 millisecond:100
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
    92
     AbsoluteTime UTCYear:1999 month:7 day:1 hour:1 minute:0 second:0 millisecond:0
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
    93
     AbsoluteTime UTCYear:2000 month:1 day:1 hour:1 minute:0 second:0 millisecond:0
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
    94
    "
1228
127d990e2f77 commentary
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
    95
4378
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
    96
    "Modified: / 1.7.1996 / 15:22:07 / cg"
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
    97
    "Created: / 13.7.1999 / 12:34:37 / stefan"
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
    98
    "Modified: / 13.7.1999 / 12:42:30 / stefan"
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
    99
!
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   100
5376
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   101
basicReadFrom:aStringOrStream
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   102
    "return a new AbsoluteTime, reading a printed representation from aStream.
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   103
     The string is interpreted as 24 hour format, as printed.
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   104
     Notice, that this is not the storeString format and 
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   105
     is different from the format expected by readFrom:.
5677
52bd6bf1775f us/non-us format reading ($/ as separator: us-format)
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
   106
     KLUDGE: 
52bd6bf1775f us/non-us format reading ($/ as separator: us-format)
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
   107
        us and non-us format have different ordering of day and month;
52bd6bf1775f us/non-us format reading ($/ as separator: us-format)
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
   108
        The format read here is (non-us) dd-mm-yyyy hh:mm:ss.iii
52bd6bf1775f us/non-us format reading ($/ as separator: us-format)
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
   109
        or (us-format, for Travis) mm/dd/yyyy hh:mm:ss.iii.
5376
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   110
     On error, raise an exception"
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   111
5677
52bd6bf1775f us/non-us format reading ($/ as separator: us-format)
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
   112
    |str first second day month year hour min sec millis usFormat|
5376
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   113
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   114
    str := aStringOrStream readStream.
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   115
5677
52bd6bf1775f us/non-us format reading ($/ as separator: us-format)
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
   116
    first := Integer readFrom:str.
52bd6bf1775f us/non-us format reading ($/ as separator: us-format)
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
   117
52bd6bf1775f us/non-us format reading ($/ as separator: us-format)
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
   118
    usFormat := (str peek == $/ ).
5376
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   119
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   120
    [str peek isDigit] whileFalse:[str next].
5677
52bd6bf1775f us/non-us format reading ($/ as separator: us-format)
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
   121
    second := Integer readFrom:str.
52bd6bf1775f us/non-us format reading ($/ as separator: us-format)
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
   122
52bd6bf1775f us/non-us format reading ($/ as separator: us-format)
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
   123
    usFormat ifTrue:[
52bd6bf1775f us/non-us format reading ($/ as separator: us-format)
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
   124
        month := first.
52bd6bf1775f us/non-us format reading ($/ as separator: us-format)
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
   125
        day := second.
52bd6bf1775f us/non-us format reading ($/ as separator: us-format)
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
   126
    ] ifFalse:[
52bd6bf1775f us/non-us format reading ($/ as separator: us-format)
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
   127
        month := second.
52bd6bf1775f us/non-us format reading ($/ as separator: us-format)
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
   128
        day := first.
52bd6bf1775f us/non-us format reading ($/ as separator: us-format)
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
   129
    ].
52bd6bf1775f us/non-us format reading ($/ as separator: us-format)
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
   130
52bd6bf1775f us/non-us format reading ($/ as separator: us-format)
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
   131
    (day between:1 and:31) ifFalse:[ Error raiseErrorString:'bad day' ].
5376
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   132
    (month between:1 and:12) ifFalse:[ Error raiseErrorString:'bad month' ].
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   133
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   134
    [str peek isDigit] whileFalse:[str next].
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   135
    year := Integer readFrom:str.
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   136
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   137
    [str peek isDigit] whileFalse:[str next].
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   138
    hour := Integer readFrom:str.
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   139
    (hour between:0 and:24) ifFalse:[ Error raiseErrorString:'bad hour' ].
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   140
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   141
    [str peek isDigit] whileFalse:[str next].
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   142
    min := Integer readFrom:str.
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   143
    (min between:0 and:59) ifFalse:[ Error raiseErrorString:'bad minute' ].
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   144
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   145
    str atEnd ifTrue:[
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   146
        sec := millis := 0.
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   147
    ] ifFalse:[
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   148
        [str peek isDigit] whileFalse:[str next].
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   149
        sec := Integer readFrom:str.
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   150
        (sec between:0 and:59) ifFalse:[ Error raiseErrorString:'bad second' ].
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   151
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   152
        str peek = $. ifTrue:[
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   153
            str next.
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   154
            millis := Integer readFrom:str.
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   155
            millis >= 1000 ifTrue:[ Error raiseErrorString:'bad millisecond' ].
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   156
        ] ifFalse:[
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   157
            millis := 0.
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   158
        ].
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   159
    ].
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   160
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   161
    "special check - only 24:00:00 is allowed;
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   162
     every time after that must wrap"
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   163
    hour == 24 ifTrue:[
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   164
        (min ~~ 0 or:[sec ~~ 0 or:[millis ~~ 0]]) ifTrue:[ Error raiseErrorString:'bad hour' ].
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   165
    ].
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   166
    ^ self year:year month:month day:day hour:hour minute:min second:sec millisecond:millis.
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   167
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   168
    "
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   169
     AbsoluteTime basicReadFrom:'20-2-1995 13:11:06'    
5677
52bd6bf1775f us/non-us format reading ($/ as separator: us-format)
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
   170
     (AbsoluteTime basicReadFrom:'10-9-1995 13:11:06') month   
52bd6bf1775f us/non-us format reading ($/ as separator: us-format)
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
   171
     (AbsoluteTime basicReadFrom:'10/9/1995 13:11:06') month   
5376
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   172
     AbsoluteTime basicReadFrom:'20-2-1995 13:11'       
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   173
     AbsoluteTime basicReadFrom:'20-2-1995 13:11:06.100'    
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   174
     AbsoluteTime basicReadFrom:'32-2-1995 13:11:06.100'  
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   175
     AbsoluteTime basicReadFrom:'32-foo-1995 13:11:06.100' 
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   176
     AbsoluteTime basicReadFrom:'20-13-1995 13:11:06.100'   
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   177
     AbsoluteTime basicReadFrom:'20-12-1995 25:11:06.100'   
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   178
     AbsoluteTime basicReadFrom:'20-12-1995 23:61:06.100'   
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   179
     AbsoluteTime basicReadFrom:'20-12-1995 23:10:66.100'   
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   180
     AbsoluteTime basicReadFrom:'20-12-1995 23:10:00.1000'   
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   181
     AbsoluteTime basicReadFrom:'20-2-1995 24:01:00.100' 
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   182
     AbsoluteTime basicReadFrom:'20-2-1995 24:00:01.100' 
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   183
     AbsoluteTime basicReadFrom:'foo'                    
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   184
     AbsoluteTime basicReadFrom:(AbsoluteTime now storeString)                  
5677
52bd6bf1775f us/non-us format reading ($/ as separator: us-format)
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
   185
    "!
5376
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   186
4378
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   187
day:d month:m year:y hour:h minutes:min seconds:s
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   188
    "This is obsolete. User #year:month:day:hour:minute:second:"
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   189
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   190
    ^ self 
4679
957773d921a8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4378
diff changeset
   191
	year:y month:m day:d hour:h 
957773d921a8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4378
diff changeset
   192
	minute:min second:s millisecond:0
4378
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   193
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   194
    "
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   195
     AbsoluteTime day:2 month:1 year:1991 hour:12 minute:30 second:0 
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   196
     AbsoluteTime day:8 month:1 year:1995 hour:0 minute:43 second:48 
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   197
    "
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   198
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   199
    "Modified: / 1.7.1996 / 15:22:26 / cg"
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   200
    "Modified: / 13.7.1999 / 12:29:56 / stefan"
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   201
!
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   202
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   203
day:d month:m year:y hour:h minutes:min seconds:s milliseconds:millis
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   204
    "This is obsolete. User #year:month:day:hour:minute:second:millisecond:"
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   205
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   206
    ^ self year:y month:m day:d hour:h minute:min second:s millisecond:millis
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   207
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   208
    "
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   209
     AbsoluteTime day:1 month:1 year:1970 hour:1 minute:0 second:0 
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   210
     AbsoluteTime day:2 month:1 year:1991 hour:12 minute:30 second:0 
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   211
     AbsoluteTime day:2 month:1 year:1991 hour:12 minute:30 second:0 millisecond:100
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   212
    "
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   213
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   214
    "Created: / 1.7.1996 / 14:46:09 / cg"
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   215
    "Modified: / 1.7.1996 / 15:22:07 / cg"
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   216
    "Modified: / 13.7.1999 / 12:30:26 / stefan"
275
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   217
!
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   218
5379
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   219
decodeFromLiteralArray:anArray
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   220
    "decode an AbsoluteTime literalArray.
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   221
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   222
     anArray may be:
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   223
        #(AbsoluteTime '200004182000.123')
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   224
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   225
     or the deprecated old format, that is not portable between different architectures.
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   226
     We parse this for backward compatibility (will be eventually removed).
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   227
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   228
        #(AbsoluteTime #osTime: 12345678)     
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   229
    "
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   230
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   231
    (anArray at:2) == #osTime: ifTrue:[
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   232
        ^ self new osTime:(anArray at:3).
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   233
    ].
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   234
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   235
    ^ self readGeneralizedFrom:(anArray at:2) onError:[self error:'literal array decoding']
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   236
!
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   237
423
claus
parents: 392
diff changeset
   238
fromDate:aDate andTime:aTime
claus
parents: 392
diff changeset
   239
    "return an instance of the receiver, initialized from a time and a date
1228
127d990e2f77 commentary
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   240
     object.
127d990e2f77 commentary
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   241
     See also `AbsoluteTime now' and other protocol inherited
127d990e2f77 commentary
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   242
     from my superclass."
423
claus
parents: 392
diff changeset
   243
claus
parents: 392
diff changeset
   244
    ^ self 
4679
957773d921a8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4378
diff changeset
   245
	year:aDate year 
957773d921a8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4378
diff changeset
   246
	month:aDate month 
957773d921a8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4378
diff changeset
   247
	day:aDate day 
957773d921a8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4378
diff changeset
   248
	hour:aTime hours 
957773d921a8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4378
diff changeset
   249
	minute:aTime minutes 
957773d921a8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4378
diff changeset
   250
	second:aTime seconds 
423
claus
parents: 392
diff changeset
   251
claus
parents: 392
diff changeset
   252
    "
1228
127d990e2f77 commentary
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   253
     AbsoluteTime fromDate:(Date today) andTime:(Time now)  
127d990e2f77 commentary
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   254
     AbsoluteTime fromDate:(Date today plusDays:1) andTime:(Time now) 
127d990e2f77 commentary
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   255
     AbsoluteTime now 
423
claus
parents: 392
diff changeset
   256
    "
claus
parents: 392
diff changeset
   257
4378
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   258
    "Modified: / 8.9.1995 / 15:07:30 / claus"
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   259
    "Modified: / 19.4.1996 / 15:25:46 / cg"
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   260
    "Modified: / 13.7.1999 / 12:30:47 / stefan"
423
claus
parents: 392
diff changeset
   261
!
claus
parents: 392
diff changeset
   262
1513
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   263
newDay:dayInYear year:year
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   264
    "return a new AbsoluteTime, given the year and the day-in-year (starting at 1).
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   265
     Date protocol compatibility"
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   266
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   267
    ^ (Date newDay:dayInYear year:year) asAbsoluteTime
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   268
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   269
    "
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   270
     AbsoluteTime newDay:183 year:1996
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   271
    "
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   272
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   273
    "Modified: 2.7.1996 / 09:39:30 / cg"
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   274
!
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   275
569
7134eb78cf48 readFrom:onError: can now also read from a string
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   276
readFrom:aStringOrStream onError:exceptionBlock
275
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   277
    "return a new AbsoluteTime, reading a printed representation from aStream.
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   278
     The string is interpreted as 24 hour format, as printed.
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   279
     Notice, that this is not the storeString format and 
4898
a7a32af11523 oops - reading was wrong
Claus Gittinger <cg@exept.de>
parents: 4843
diff changeset
   280
     is different from the format expected by readFrom:.
a7a32af11523 oops - reading was wrong
Claus Gittinger <cg@exept.de>
parents: 4843
diff changeset
   281
     The format read here is dd-mm-yyyy hh:mm:ss.iii"
275
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   282
3995
777470826394 no need for another error-handler blcok in #readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 3510
diff changeset
   283
    |newTime|
275
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   284
3995
777470826394 no need for another error-handler blcok in #readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 3510
diff changeset
   285
    ErrorSignal handle:[:ex |
5376
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   286
        ^ super readFrom:aStringOrStream onError:exceptionBlock 
3995
777470826394 no need for another error-handler blcok in #readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 3510
diff changeset
   287
    ] do:[
5376
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   288
        newTime := self basicReadFrom:aStringOrStream.
275
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   289
    ].
3995
777470826394 no need for another error-handler blcok in #readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 3510
diff changeset
   290
    ^ newTime
275
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   291
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   292
    "
5376
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   293
     AbsoluteTime readFrom:'20-2-1995 13:11:06'                            
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   294
     AbsoluteTime readFrom:'20-2-1995 13:11'                               
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   295
     AbsoluteTime readFrom:'20-2-2001 13:11'                               
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   296
     AbsoluteTime readFrom:'20-2-1995 13:11:06.100'                        
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   297
     AbsoluteTime readFrom:'32-2-1995 13:11:06.100' onError:'wrong'        
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   298
     AbsoluteTime readFrom:'32-foo-1995 13:11:06.100' onError:'wrong'      
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   299
     AbsoluteTime readFrom:'20-2-1995 24:01:00.100' onError:'wrong'        
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   300
     AbsoluteTime readFrom:'20-2-1995 24:00:01.100' onError:'wrong'        
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   301
     AbsoluteTime readFrom:'foo' onError:'wrong'                           
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   302
     AbsoluteTime readFrom:(AbsoluteTime now storeString) onError:'wrong'                     
275
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   303
    "
569
7134eb78cf48 readFrom:onError: can now also read from a string
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   304
4378
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   305
    "Modified: / 8.10.1996 / 19:25:59 / cg"
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   306
    "Modified: / 13.7.1999 / 12:31:14 / stefan"
2311
88b035dd471a New Method: #secondsSince1970.
Stefan Vogel <sv@exept.de>
parents: 1701
diff changeset
   307
!
88b035dd471a New Method: #secondsSince1970.
Stefan Vogel <sv@exept.de>
parents: 1701
diff changeset
   308
5292
a3936f79327b Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents: 5291
diff changeset
   309
readGeneralizedFrom:aStringOrStream onError:exceptionBlock
a3936f79327b Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents: 5291
diff changeset
   310
    "return a new AbsoluteTime, reading a printed representation from aStream.
a3936f79327b Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents: 5291
diff changeset
   311
     The string is interpreted as 24 hour format, as printed.
5376
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   312
5292
a3936f79327b Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents: 5291
diff changeset
   313
     Notice, that this is not the storeString format and 
a3936f79327b Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents: 5291
diff changeset
   314
     is different from the format expected by readFrom:.
5376
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   315
     The format read here is yyyymmddHHMMSS.iii+uuuu,
c2ef7d5e25ca oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents: 5292
diff changeset
   316
     which is the ASN1 GeneralizedTime format."
5292
a3936f79327b Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents: 5291
diff changeset
   317
a3936f79327b Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents: 5291
diff changeset
   318
    |newTime|
a3936f79327b Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents: 5291
diff changeset
   319
a3936f79327b Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents: 5291
diff changeset
   320
    ErrorSignal handle:[:ex |
a3936f79327b Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents: 5291
diff changeset
   321
        ^ exceptionBlock value
a3936f79327b Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents: 5291
diff changeset
   322
    ] do:[
a3936f79327b Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents: 5291
diff changeset
   323
        |str day month year hour min sec millis c|
a3936f79327b Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents: 5291
diff changeset
   324
a3936f79327b Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents: 5291
diff changeset
   325
        sec := millis := 0.
a3936f79327b Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents: 5291
diff changeset
   326
        str := aStringOrStream readStream.
a3936f79327b Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents: 5291
diff changeset
   327
a3936f79327b Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents: 5291
diff changeset
   328
        year := Integer readFrom:(str next:4).
a3936f79327b Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents: 5291
diff changeset
   329
        month := Integer readFrom:(str next:2).
a3936f79327b Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents: 5291
diff changeset
   330
        (month between:1 and:12) ifFalse:[^ exceptionBlock value].
a3936f79327b Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents: 5291
diff changeset
   331
        day := Integer readFrom:(str next:2).
a3936f79327b Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents: 5291
diff changeset
   332
        (day between:1 and:31) ifFalse:[^ exceptionBlock value].
a3936f79327b Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents: 5291
diff changeset
   333
        hour:= Integer readFrom:(str next:2).
a3936f79327b Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents: 5291
diff changeset
   334
        (hour between:0 and:24) ifFalse:[^ exceptionBlock value].
a3936f79327b Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents: 5291
diff changeset
   335
        min:= Integer readFrom:(str next:2).
a3936f79327b Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents: 5291
diff changeset
   336
        (min between:0 and:59) ifFalse:[^ exceptionBlock value].
a3936f79327b Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents: 5291
diff changeset
   337
        str atEnd ifFalse:[
a3936f79327b Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents: 5291
diff changeset
   338
            sec := Integer readFrom:(str next:2).
a3936f79327b Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents: 5291
diff changeset
   339
            (sec between:0 and:59) ifFalse:[^ exceptionBlock value].
a3936f79327b Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents: 5291
diff changeset
   340
            str peek == $. ifTrue:[
a3936f79327b Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents: 5291
diff changeset
   341
                str next.
a3936f79327b Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents: 5291
diff changeset
   342
                millis := Integer readFrom:str.
a3936f79327b Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents: 5291
diff changeset
   343
            ].
a3936f79327b Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents: 5291
diff changeset
   344
        ]. 
a3936f79327b Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents: 5291
diff changeset
   345
        str atEnd ifTrue:[
a3936f79327b Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents: 5291
diff changeset
   346
            "/ this is local time
a3936f79327b Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents: 5291
diff changeset
   347
            newTime := self year:year month:month day:day 
a3936f79327b Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents: 5291
diff changeset
   348
                              hour:hour minute:min second:sec millisecond:millis.
a3936f79327b Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents: 5291
diff changeset
   349
        ] ifFalse:[
a3936f79327b Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents: 5291
diff changeset
   350
            c := str next.
a3936f79327b Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents: 5291
diff changeset
   351
            c ~~ $Z ifTrue:[ |tzh tzmin|
a3936f79327b Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents: 5291
diff changeset
   352
                tzh := Integer readFrom:(str next:2).
a3936f79327b Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents: 5291
diff changeset
   353
                tzmin := Integer readFrom:(str next:2).
a3936f79327b Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents: 5291
diff changeset
   354
                c == $+ ifTrue:[
5656
dbc52ea02716 Fix UTC Time w.r.t. Daylight saving time.
Stefan Vogel <sv@exept.de>
parents: 5572
diff changeset
   355
                    "/ add hours and minutes
dbc52ea02716 Fix UTC Time w.r.t. Daylight saving time.
Stefan Vogel <sv@exept.de>
parents: 5572
diff changeset
   356
                    hour := hour + tzh.
dbc52ea02716 Fix UTC Time w.r.t. Daylight saving time.
Stefan Vogel <sv@exept.de>
parents: 5572
diff changeset
   357
                    min := min + tzmin.
5292
a3936f79327b Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents: 5291
diff changeset
   358
                ] ifFalse:[
a3936f79327b Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents: 5291
diff changeset
   359
                    c ~~ $- ifTrue:[
a3936f79327b Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents: 5291
diff changeset
   360
                       self error:'bad time offset'.
a3936f79327b Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents: 5291
diff changeset
   361
                    ].
5656
dbc52ea02716 Fix UTC Time w.r.t. Daylight saving time.
Stefan Vogel <sv@exept.de>
parents: 5572
diff changeset
   362
                    "/ subtract hours and minutes
dbc52ea02716 Fix UTC Time w.r.t. Daylight saving time.
Stefan Vogel <sv@exept.de>
parents: 5572
diff changeset
   363
                    hour := hour - tzh.
dbc52ea02716 Fix UTC Time w.r.t. Daylight saving time.
Stefan Vogel <sv@exept.de>
parents: 5572
diff changeset
   364
                    min := min - tzmin.
5292
a3936f79327b Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents: 5291
diff changeset
   365
                ].
a3936f79327b Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents: 5291
diff changeset
   366
            ].
a3936f79327b Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents: 5291
diff changeset
   367
            "/ this is UTC time
a3936f79327b Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents: 5291
diff changeset
   368
            newTime := self UTCYear:year month:month day:day 
a3936f79327b Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents: 5291
diff changeset
   369
                              hour:hour minute:min second:sec millisecond:millis.
a3936f79327b Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents: 5291
diff changeset
   370
        ].
a3936f79327b Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents: 5291
diff changeset
   371
    ].
a3936f79327b Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents: 5291
diff changeset
   372
    ^ newTime
a3936f79327b Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents: 5291
diff changeset
   373
a3936f79327b Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents: 5291
diff changeset
   374
    "
5656
dbc52ea02716 Fix UTC Time w.r.t. Daylight saving time.
Stefan Vogel <sv@exept.de>
parents: 5572
diff changeset
   375
     |s|
dbc52ea02716 Fix UTC Time w.r.t. Daylight saving time.
Stefan Vogel <sv@exept.de>
parents: 5572
diff changeset
   376
     s := '' writeStream.
dbc52ea02716 Fix UTC Time w.r.t. Daylight saving time.
Stefan Vogel <sv@exept.de>
parents: 5572
diff changeset
   377
     AbsoluteTime now printGeneralizedOn:s.
dbc52ea02716 Fix UTC Time w.r.t. Daylight saving time.
Stefan Vogel <sv@exept.de>
parents: 5572
diff changeset
   378
     AbsoluteTime readGeneralizedFrom:s contents onError:[]
dbc52ea02716 Fix UTC Time w.r.t. Daylight saving time.
Stefan Vogel <sv@exept.de>
parents: 5572
diff changeset
   379
dbc52ea02716 Fix UTC Time w.r.t. Daylight saving time.
Stefan Vogel <sv@exept.de>
parents: 5572
diff changeset
   380
     AbsoluteTime readGeneralizedFrom:'20001018000000+0200' onError:[]
dbc52ea02716 Fix UTC Time w.r.t. Daylight saving time.
Stefan Vogel <sv@exept.de>
parents: 5572
diff changeset
   381
     AbsoluteTime readGeneralizedFrom:'20001018000000+0300' onError:[]
dbc52ea02716 Fix UTC Time w.r.t. Daylight saving time.
Stefan Vogel <sv@exept.de>
parents: 5572
diff changeset
   382
dbc52ea02716 Fix UTC Time w.r.t. Daylight saving time.
Stefan Vogel <sv@exept.de>
parents: 5572
diff changeset
   383
     AbsoluteTime readGeneralizedFrom:'20000202000000+0100' onError:[]
dbc52ea02716 Fix UTC Time w.r.t. Daylight saving time.
Stefan Vogel <sv@exept.de>
parents: 5572
diff changeset
   384
     AbsoluteTime readGeneralizedFrom:'20000202000000+0200' onError:[]
dbc52ea02716 Fix UTC Time w.r.t. Daylight saving time.
Stefan Vogel <sv@exept.de>
parents: 5572
diff changeset
   385
5292
a3936f79327b Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents: 5291
diff changeset
   386
     AbsoluteTime readGeneralizedFrom:'19950220131106' onError:[]   
a3936f79327b Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents: 5291
diff changeset
   387
     AbsoluteTime readGeneralizedFrom:'199502201311' onError:[]    
a3936f79327b Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents: 5291
diff changeset
   388
     AbsoluteTime readGeneralizedFrom:'19950220131106.100' onError:[]    
a3936f79327b Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents: 5291
diff changeset
   389
     AbsoluteTime readGeneralizedFrom:'19950232131106.100' onError:'wrong'    
a3936f79327b Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents: 5291
diff changeset
   390
     AbsoluteTime readGeneralizedFrom:'19950fo2131106.100' onError:'wrong'    
a3936f79327b Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents: 5291
diff changeset
   391
     AbsoluteTime readGeneralizedFrom:'foo' onError:'wrong'                     
a3936f79327b Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents: 5291
diff changeset
   392
    "
a3936f79327b Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents: 5291
diff changeset
   393
a3936f79327b Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents: 5291
diff changeset
   394
    "Modified: / 8.10.1996 / 19:25:59 / cg"
a3936f79327b Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents: 5291
diff changeset
   395
    "Modified: / 13.7.1999 / 12:31:14 / stefan"
a3936f79327b Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents: 5291
diff changeset
   396
!
a3936f79327b Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents: 5291
diff changeset
   397
2311
88b035dd471a New Method: #secondsSince1970.
Stefan Vogel <sv@exept.de>
parents: 1701
diff changeset
   398
secondsSince1970:sec
88b035dd471a New Method: #secondsSince1970.
Stefan Vogel <sv@exept.de>
parents: 1701
diff changeset
   399
    "set time from elapsed seconds since 1-1-1970, 0:0:0.
88b035dd471a New Method: #secondsSince1970.
Stefan Vogel <sv@exept.de>
parents: 1701
diff changeset
   400
     This is the format used in the UNIX world"
88b035dd471a New Method: #secondsSince1970.
Stefan Vogel <sv@exept.de>
parents: 1701
diff changeset
   401
4378
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   402
    ^ self year:1970 month:1 day:1 hour:0 minute:0 second:sec.
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   403
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   404
    "
4679
957773d921a8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4378
diff changeset
   405
	AbsoluteTime secondsSince1970:0
957773d921a8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4378
diff changeset
   406
	AbsoluteTime secondsSince1970:3600
4378
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   407
    "
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   408
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   409
    "Created: / 21.10.1996 / 17:48:30 / stefan"
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   410
    "Modified: / 13.7.1999 / 12:31:22 / stefan"
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   411
!
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   412
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   413
year:y month:m day:d hour:h minute:min second:s
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   414
    "return an instance of the receiver, given individual components.
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   415
     See also `AbsoluteTime now' and other protocol inherited
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   416
     from my superclass."
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   417
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   418
    ^ self year:y month:m day:d hour:h minute:min second:s millisecond:0
2311
88b035dd471a New Method: #secondsSince1970.
Stefan Vogel <sv@exept.de>
parents: 1701
diff changeset
   419
88b035dd471a New Method: #secondsSince1970.
Stefan Vogel <sv@exept.de>
parents: 1701
diff changeset
   420
    "
4378
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   421
     AbsoluteTime year:1970 month:1 day:1 hour:1 minute:0 second:0 
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   422
     AbsoluteTime year:1991 month:1 day:2 hour:12 minute:30 second:0 
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   423
     AbsoluteTime year:1991 month:1 day:2 hour:12 minute:30 second:0 millisecond:100
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   424
     AbsoluteTime year:2000 month:1 day:1 hour:1 minutes:0 second:0 
2311
88b035dd471a New Method: #secondsSince1970.
Stefan Vogel <sv@exept.de>
parents: 1701
diff changeset
   425
    "
88b035dd471a New Method: #secondsSince1970.
Stefan Vogel <sv@exept.de>
parents: 1701
diff changeset
   426
4378
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   427
    "Modified: / 1.7.1996 / 15:22:07 / cg"
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   428
    "Created: / 13.7.1999 / 12:06:39 / stefan"
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   429
    "Modified: / 13.7.1999 / 12:27:47 / stefan"
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   430
!
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   431
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   432
year:y month:m day:d hour:h minute:min second:s millisecond:millis
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   433
    "return an instance of the receiver, given individual components.
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   434
     See also `AbsoluteTime now' and other protocol inherited
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   435
     from my superclass."
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   436
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   437
    ^ self basicNew 
4679
957773d921a8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4378
diff changeset
   438
	fromOSTime:(OperatingSystem 
957773d921a8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4378
diff changeset
   439
			computeOSTimeFromYear:y month:m day:d 
957773d921a8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4378
diff changeset
   440
					 hour:h minute:min seconds:s millis:millis)
4378
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   441
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   442
    "
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   443
     AbsoluteTime year:1970 month:1 day:1 hour:1 minute:0 seconds:0 
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   444
     AbsoluteTime year:1991 month:1 day:2 hour:12 minute:30 second:0 
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   445
     AbsoluteTime year:1991 month:1 day:2 hour:12 minute:30 second:0 millisecond:100
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   446
     AbsoluteTime year:2000 month:1 day:1 hour:1 minute:0 second:0 
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   447
    "
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   448
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   449
    "Modified: / 1.7.1996 / 15:22:07 / cg"
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   450
    "Created: / 13.7.1999 / 12:28:44 / stefan"
8b93493f8d56 New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 3995
diff changeset
   451
    "Modified: / 13.7.1999 / 12:37:57 / stefan"
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   452
! !
30
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
   453
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
   454
!AbsoluteTime methodsFor:'accessing'!
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
   455
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
   456
day
92
0c73b48551ac *** empty log message ***
claus
parents: 82
diff changeset
   457
    "return the day-in-month of the receiver (1..31).
275
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   458
     For compatibility, use instances of Date for this."
30
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
   459
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   460
    |d|
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   461
275
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   462
    OperatingSystem computeDatePartsOf:osTime for:[:year :month :day |
3120
56348e25a94f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2623
diff changeset
   463
	d := day
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   464
    ].
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   465
    ^ d
54
06dbdeeed4f9 *** empty log message ***
claus
parents: 30
diff changeset
   466
92
0c73b48551ac *** empty log message ***
claus
parents: 82
diff changeset
   467
    "
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   468
     AbsoluteTime now day 
92
0c73b48551ac *** empty log message ***
claus
parents: 82
diff changeset
   469
    "
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   470
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   471
    "Modified: 1.7.1996 / 15:23:02 / cg"
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   472
!
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   473
1513
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   474
dayInWeek
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   475
    "return the week-day of the receiver - 1 for monday, 7 for sunday"
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   476
3120
56348e25a94f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2623
diff changeset
   477
    ^ (OperatingSystem computeTimeAndDateFrom:osTime) at:11
1513
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   478
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   479
    "
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   480
     AbsoluteTime now dayInWeek 
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   481
    "
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   482
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   483
    "Modified: 2.7.1996 / 09:20:32 / cg"
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   484
    "Created: 2.7.1996 / 09:35:48 / cg"
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   485
!
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   486
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   487
dayInYear
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   488
    "return the year-day of the receiver - 1 for Jan, 1st."
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   489
3120
56348e25a94f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2623
diff changeset
   490
    ^ (OperatingSystem computeTimeAndDateFrom:osTime) at:10
1513
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   491
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   492
    "
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   493
     AbsoluteTime now dayInYear  
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   494
     AbsoluteTime newDay:184 year:1996  
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   495
    "
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   496
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   497
    "Modified: 2.7.1996 / 10:21:02 / cg"
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   498
!
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   499
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   500
hour
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   501
    "return the hour (0..23).
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   502
     ST-80 Timestamp compatibility (I'd prefer the name #hours, for Time compatibility)."
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   503
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   504
    ^ self hours
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   505
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   506
    "Created: 1.7.1996 / 15:14:50 / cg"
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   507
    "Modified: 1.7.1996 / 15:15:32 / cg"
30
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
   508
!
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
   509
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   510
hours
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   511
    "return the hours (0..23)"
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   512
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   513
    |hr|
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   514
1513
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   515
    OperatingSystem computeTimePartsOf:osTime for:[:hours :minutes :secs :millis |
3120
56348e25a94f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2623
diff changeset
   516
	hr := hours
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   517
    ].
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   518
    ^ hr
54
06dbdeeed4f9 *** empty log message ***
claus
parents: 30
diff changeset
   519
92
0c73b48551ac *** empty log message ***
claus
parents: 82
diff changeset
   520
    "
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   521
     AbsoluteTime now hours 
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   522
    "
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   523
1513
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   524
    "Modified: 2.7.1996 / 09:20:32 / cg"
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   525
!
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   526
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   527
millisecond
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   528
    "return the millisecond (0..999).
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   529
     ST-80 Timestamp compatibility (I'd prefer the name #milliseconds)."
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   530
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   531
    ^ self milliseconds
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   532
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   533
    "Created: 1.7.1996 / 15:14:50 / cg"
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   534
    "Modified: 1.7.1996 / 15:15:24 / cg"
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   535
!
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   536
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   537
milliseconds
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   538
    "return the milliseconds (0..999)"
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   539
1513
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   540
    |m|
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   541
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   542
    OperatingSystem computeTimePartsOf:osTime for:[:hours :minutes :secs :millis |
3120
56348e25a94f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2623
diff changeset
   543
	m := millis
1513
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   544
    ].
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   545
    ^ m
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   546
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   547
    "
1513
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   548
     AbsoluteTime now milliseconds   
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   549
    "
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   550
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   551
    "Created: 1.7.1996 / 15:15:02 / cg"
1513
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   552
    "Modified: 2.7.1996 / 09:21:41 / cg"
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   553
!
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   554
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   555
minute
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   556
    "return the minute (0..59).
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   557
     ST-80 Timestamp compatibility (I'd prefer the name #minutes, for Time compatibility)."
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   558
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   559
    ^ self minutes
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   560
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   561
    "Created: 1.7.1996 / 15:14:29 / cg"
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   562
    "Modified: 1.7.1996 / 15:15:37 / cg"
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   563
!
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   564
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   565
minutes
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   566
    "return the minutes (0..59)"
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   567
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   568
    |m|
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   569
1513
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   570
    OperatingSystem computeTimePartsOf:osTime for:[:hours :minutes :secs :millis |
3120
56348e25a94f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2623
diff changeset
   571
	m := minutes
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   572
    ].
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   573
    ^ m
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   574
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   575
    "
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   576
     AbsoluteTime now minutes 
92
0c73b48551ac *** empty log message ***
claus
parents: 82
diff changeset
   577
    "
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   578
1513
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   579
    "Modified: 2.7.1996 / 09:20:49 / cg"
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   580
!
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   581
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   582
month
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   583
    "return the month of the receiver (1..12).
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   584
     For compatibility, use instances of Date for this."
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   585
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   586
    |m|
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   587
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   588
    OperatingSystem computeDatePartsOf:osTime for:[ :year :month :day |
3120
56348e25a94f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2623
diff changeset
   589
	m := month
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   590
    ].
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   591
    ^ m
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   592
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   593
    "
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   594
     AbsoluteTime now month
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   595
    "
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   596
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   597
    "Modified: 1.7.1996 / 15:23:05 / cg"
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   598
!
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   599
4807
Claus Gittinger <cg@exept.de>
parents: 4679
diff changeset
   600
osTime:aTime
Claus Gittinger <cg@exept.de>
parents: 4679
diff changeset
   601
    osTime := aTime.
Claus Gittinger <cg@exept.de>
parents: 4679
diff changeset
   602
!
Claus Gittinger <cg@exept.de>
parents: 4679
diff changeset
   603
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   604
second
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   605
    "return the second (0..59).
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   606
     ST-80 Timestamp compatibility (I'd prefer the name #seconds, for Time compatibility)."
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   607
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   608
    ^ self seconds
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   609
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   610
    "Created: 1.7.1996 / 15:14:19 / cg"
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   611
    "Modified: 1.7.1996 / 15:15:49 / cg"
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   612
!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   613
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   614
seconds
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   615
    "return the seconds (0..59)"
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   616
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   617
    |s|
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   618
1513
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   619
    OperatingSystem computeTimePartsOf:osTime for:[:hours :minutes :secs :millis |
3120
56348e25a94f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2623
diff changeset
   620
	s := secs
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   621
    ].
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   622
    ^ s
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   623
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   624
    "
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   625
     AbsoluteTime now seconds 
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   626
    "
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   627
1513
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   628
    "Modified: 2.7.1996 / 09:20:54 / cg"
92
0c73b48551ac *** empty log message ***
claus
parents: 82
diff changeset
   629
!
0c73b48551ac *** empty log message ***
claus
parents: 82
diff changeset
   630
799
33cf42458eee New Method utcOffset
Stefan Vogel <sv@exept.de>
parents: 795
diff changeset
   631
utcOffset
33cf42458eee New Method utcOffset
Stefan Vogel <sv@exept.de>
parents: 795
diff changeset
   632
    "return the difference between UTC (Greenwich Mean Time) and the local time
33cf42458eee New Method utcOffset
Stefan Vogel <sv@exept.de>
parents: 795
diff changeset
   633
     if daylight saving time applies to ourself, take that into account.
33cf42458eee New Method utcOffset
Stefan Vogel <sv@exept.de>
parents: 795
diff changeset
   634
     Add utcOffset bevor converting to get UTC-Time resp. UTC-Date.
33cf42458eee New Method utcOffset
Stefan Vogel <sv@exept.de>
parents: 795
diff changeset
   635
    "
33cf42458eee New Method utcOffset
Stefan Vogel <sv@exept.de>
parents: 795
diff changeset
   636
33cf42458eee New Method utcOffset
Stefan Vogel <sv@exept.de>
parents: 795
diff changeset
   637
    ^ (OperatingSystem computeTimeAndDateFrom:osTime) at:7
33cf42458eee New Method utcOffset
Stefan Vogel <sv@exept.de>
parents: 795
diff changeset
   638
33cf42458eee New Method utcOffset
Stefan Vogel <sv@exept.de>
parents: 795
diff changeset
   639
    "
33cf42458eee New Method utcOffset
Stefan Vogel <sv@exept.de>
parents: 795
diff changeset
   640
     AbsoluteTime now utcOffset 
33cf42458eee New Method utcOffset
Stefan Vogel <sv@exept.de>
parents: 795
diff changeset
   641
     (AbsoluteTime day:1 month:7 year:1995 hour:12 minutes:0 seconds:0) utcOffset
33cf42458eee New Method utcOffset
Stefan Vogel <sv@exept.de>
parents: 795
diff changeset
   642
    "
33cf42458eee New Method utcOffset
Stefan Vogel <sv@exept.de>
parents: 795
diff changeset
   643
33cf42458eee New Method utcOffset
Stefan Vogel <sv@exept.de>
parents: 795
diff changeset
   644
    "Modified: 20.12.1995 / 17:28:49 / stefan"
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   645
    "Modified: 1.7.1996 / 15:21:29 / cg"
799
33cf42458eee New Method utcOffset
Stefan Vogel <sv@exept.de>
parents: 795
diff changeset
   646
!
33cf42458eee New Method utcOffset
Stefan Vogel <sv@exept.de>
parents: 795
diff changeset
   647
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   648
year
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   649
    "return the year of the receiver i.e. 1992.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   650
     For compatibility, use instances of Date for this."
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   651
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   652
    |y|
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   653
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   654
    OperatingSystem computeDatePartsOf:osTime for:[:year :month :day |
3120
56348e25a94f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2623
diff changeset
   655
	y := year
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   656
    ].
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   657
    ^ y
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   658
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   659
    "
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   660
     AbsoluteTime now year
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   661
    "
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   662
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   663
    "Modified: 1.7.1996 / 15:23:08 / cg"
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   664
! !
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   665
30
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
   666
!AbsoluteTime methodsFor:'arithmetic'!
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
   667
242
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   668
addDays:numberOfDays
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   669
    "return a new instance of myself, numberOfDays afterwards."
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   670
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   671
    ^ self addSeconds:(numberOfDays * (60 * 60 * 24))
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   672
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   673
    "
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   674
     |t|
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   675
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   676
     t := AbsoluteTime now.
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   677
     t printNL.
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   678
     (t addDays:7) printNL
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   679
    "
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   680
!
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   681
3122
a0be2e69caf0 added #addMilliseconds
Claus Gittinger <cg@exept.de>
parents: 3120
diff changeset
   682
addMilliseconds:nMillis
a0be2e69caf0 added #addMilliseconds
Claus Gittinger <cg@exept.de>
parents: 3120
diff changeset
   683
    "return a new absoluteTime instance, nMillis milliseconds after myself"
a0be2e69caf0 added #addMilliseconds
Claus Gittinger <cg@exept.de>
parents: 3120
diff changeset
   684
a0be2e69caf0 added #addMilliseconds
Claus Gittinger <cg@exept.de>
parents: 3120
diff changeset
   685
    ^ (self class basicNew) setMilliseconds:(self getMilliseconds + nMillis)
a0be2e69caf0 added #addMilliseconds
Claus Gittinger <cg@exept.de>
parents: 3120
diff changeset
   686
a0be2e69caf0 added #addMilliseconds
Claus Gittinger <cg@exept.de>
parents: 3120
diff changeset
   687
    "
a0be2e69caf0 added #addMilliseconds
Claus Gittinger <cg@exept.de>
parents: 3120
diff changeset
   688
     |t1 t2|
a0be2e69caf0 added #addMilliseconds
Claus Gittinger <cg@exept.de>
parents: 3120
diff changeset
   689
a0be2e69caf0 added #addMilliseconds
Claus Gittinger <cg@exept.de>
parents: 3120
diff changeset
   690
     t1 := AbsoluteTime now.
a0be2e69caf0 added #addMilliseconds
Claus Gittinger <cg@exept.de>
parents: 3120
diff changeset
   691
     t2 := t1 addMilliseconds:10.
a0be2e69caf0 added #addMilliseconds
Claus Gittinger <cg@exept.de>
parents: 3120
diff changeset
   692
     Transcript showCR:t1.   
a0be2e69caf0 added #addMilliseconds
Claus Gittinger <cg@exept.de>
parents: 3120
diff changeset
   693
     Transcript showCR:t2.   
a0be2e69caf0 added #addMilliseconds
Claus Gittinger <cg@exept.de>
parents: 3120
diff changeset
   694
    "
a0be2e69caf0 added #addMilliseconds
Claus Gittinger <cg@exept.de>
parents: 3120
diff changeset
   695
a0be2e69caf0 added #addMilliseconds
Claus Gittinger <cg@exept.de>
parents: 3120
diff changeset
   696
    "Modified: / 2.12.1997 / 17:10:39 / cg"
a0be2e69caf0 added #addMilliseconds
Claus Gittinger <cg@exept.de>
parents: 3120
diff changeset
   697
!
a0be2e69caf0 added #addMilliseconds
Claus Gittinger <cg@exept.de>
parents: 3120
diff changeset
   698
2623
593ab389efd1 added #millisecondDeltaFrom:
Claus Gittinger <cg@exept.de>
parents: 2311
diff changeset
   699
millisecondDeltaFrom:anAbsoluteTime
3510
75824285fe74 comment
Claus Gittinger <cg@exept.de>
parents: 3479
diff changeset
   700
    "return the delta in milliseconds between 2 absolute times.
75824285fe74 comment
Claus Gittinger <cg@exept.de>
parents: 3479
diff changeset
   701
     The argument is supposed to be AFTER the receiver"
2623
593ab389efd1 added #millisecondDeltaFrom:
Claus Gittinger <cg@exept.de>
parents: 2311
diff changeset
   702
593ab389efd1 added #millisecondDeltaFrom:
Claus Gittinger <cg@exept.de>
parents: 2311
diff changeset
   703
    ^ (self getSeconds - (anAbsoluteTime getSeconds)) * 1000
593ab389efd1 added #millisecondDeltaFrom:
Claus Gittinger <cg@exept.de>
parents: 2311
diff changeset
   704
      + self milliseconds - anAbsoluteTime milliseconds
593ab389efd1 added #millisecondDeltaFrom:
Claus Gittinger <cg@exept.de>
parents: 2311
diff changeset
   705
593ab389efd1 added #millisecondDeltaFrom:
Claus Gittinger <cg@exept.de>
parents: 2311
diff changeset
   706
    "
593ab389efd1 added #millisecondDeltaFrom:
Claus Gittinger <cg@exept.de>
parents: 2311
diff changeset
   707
     |t1 t2|
593ab389efd1 added #millisecondDeltaFrom:
Claus Gittinger <cg@exept.de>
parents: 2311
diff changeset
   708
593ab389efd1 added #millisecondDeltaFrom:
Claus Gittinger <cg@exept.de>
parents: 2311
diff changeset
   709
     t1 := AbsoluteTime now.
593ab389efd1 added #millisecondDeltaFrom:
Claus Gittinger <cg@exept.de>
parents: 2311
diff changeset
   710
     Delay waitForSeconds:0.5.
593ab389efd1 added #millisecondDeltaFrom:
Claus Gittinger <cg@exept.de>
parents: 2311
diff changeset
   711
     t2 := AbsoluteTime now.
593ab389efd1 added #millisecondDeltaFrom:
Claus Gittinger <cg@exept.de>
parents: 2311
diff changeset
   712
     t2 millisecondDeltaFrom:t1   
593ab389efd1 added #millisecondDeltaFrom:
Claus Gittinger <cg@exept.de>
parents: 2311
diff changeset
   713
    "
593ab389efd1 added #millisecondDeltaFrom:
Claus Gittinger <cg@exept.de>
parents: 2311
diff changeset
   714
3510
75824285fe74 comment
Claus Gittinger <cg@exept.de>
parents: 3479
diff changeset
   715
    "Modified: / 5.6.1998 / 04:21:33 / cg"
2623
593ab389efd1 added #millisecondDeltaFrom:
Claus Gittinger <cg@exept.de>
parents: 2311
diff changeset
   716
!
593ab389efd1 added #millisecondDeltaFrom:
Claus Gittinger <cg@exept.de>
parents: 2311
diff changeset
   717
242
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   718
subtractDays:numberOfDays
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   719
    "return a new instance of myself, numberOfDays before."
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   720
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   721
    ^ self subtractSeconds:(numberOfDays * (60 * 60 * 24))
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   722
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   723
    "
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   724
     |t|
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   725
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   726
     t := AbsoluteTime now.
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   727
     t printNL.
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   728
     (t subtractDays:50) printNL
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   729
    "
30
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
   730
! !
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
   731
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   732
!AbsoluteTime methodsFor:'comparing'!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   733
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   734
= aTime
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   735
    "return true if the argument, aTime represents the same time"
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   736
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   737
    (aTime species == self species) ifFalse:[^ false].
1520
da08f8e49e87 fixed comparing absoluteTimes
Claus Gittinger <cg@exept.de>
parents: 1513
diff changeset
   738
    ^ (self getMilliseconds = aTime getMilliseconds)
da08f8e49e87 fixed comparing absoluteTimes
Claus Gittinger <cg@exept.de>
parents: 1513
diff changeset
   739
da08f8e49e87 fixed comparing absoluteTimes
Claus Gittinger <cg@exept.de>
parents: 1513
diff changeset
   740
    "Modified: 3.7.1996 / 13:10:24 / cg"
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   741
!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   742
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   743
hash
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   744
    "return an integer useful for hashing on times"
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   745
1520
da08f8e49e87 fixed comparing absoluteTimes
Claus Gittinger <cg@exept.de>
parents: 1513
diff changeset
   746
    ^ osTime // 1000
da08f8e49e87 fixed comparing absoluteTimes
Claus Gittinger <cg@exept.de>
parents: 1513
diff changeset
   747
da08f8e49e87 fixed comparing absoluteTimes
Claus Gittinger <cg@exept.de>
parents: 1513
diff changeset
   748
    "Modified: 3.7.1996 / 13:10:52 / cg"
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   749
! !
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   750
5677
52bd6bf1775f us/non-us format reading ($/ as separator: us-format)
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
   751
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   752
!AbsoluteTime methodsFor:'converting'!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   753
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   754
asAbsoluteTime
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   755
    "return an AbsoluteTime object from the receiver - thats the receiver."
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   756
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   757
    ^ self
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   758
!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   759
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   760
asDate
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   761
    "return a Date object from the receiver.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   762
     The returned date will only represent the day - not the timeOfDay."
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   763
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   764
    ^ Date fromOSTime:osTime 
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   765
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   766
    "
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   767
     AbsoluteTime now  
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   768
     AbsoluteTime now asDate
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   769
     (AbsoluteTime now addTime:3600) asDate 
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   770
     (AbsoluteTime now addTime:3600) asTime 
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   771
     AbsoluteTime fromSeconds:(AbsoluteTime now asSeconds + 3600) 
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   772
     (AbsoluteTime fromSeconds:(AbsoluteTime now asSeconds + 3600)) asDate  
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   773
    "
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   774
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   775
!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   776
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   777
asSeconds
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   778
    "return the number of seconds elapsed since whatever time the
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   779
     OperatingSystem bases its time upon. Since this is totally
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   780
     OS-dependent, do not interpret the value returned by this method.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   781
     You can use it to add/subtract seconds or get time deltas, though."
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   782
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   783
    ^ self getSeconds
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   784
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   785
    "
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   786
     AbsoluteTime now asSeconds
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   787
     AbsoluteTime fromSeconds:(AbsoluteTime now asSeconds + 3600) 
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   788
     Time hour:23 minutes:33 seconds:0         
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   789
     Time fromSeconds:((Time hour:23 minutes:33 seconds:0) asSeconds + 3600) 
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   790
    "
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   791
!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   792
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   793
asTime
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   794
    "return a Time object from the receiver.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   795
     The returned time will only represent the timeOfDay - not the day."
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   796
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   797
    ^ Time fromOSTime:osTime
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   798
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   799
    "
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   800
     AbsoluteTime now  
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   801
     AbsoluteTime now asTime
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   802
     (AbsoluteTime now addTime:3600) asTime 
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   803
    "
5379
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   804
!
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   805
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   806
literalArrayEncoding
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   807
    "encode myself as an array, from which a copy of the receiver
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   808
     can be reconstructed with #decodeAsLiteralArray.
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   809
     The encoding is: 
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   810
        (#AbsoluteTime YYYYMMDDhhmmss.iii)
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   811
    "
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   812
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   813
    |s|
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   814
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   815
    s := '' writeStream.
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   816
    self printGeneralizedOn:s isLocal:true.
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   817
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   818
    ^ Array
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   819
        with:self class name asSymbol
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   820
        with:s contents
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   821
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   822
    "
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   823
      AbsoluteTime now literalArrayEncoding 
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   824
      AbsoluteTime decodeFromLiteralArray:AbsoluteTime now literalArrayEncoding
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   825
    "
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   826
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   827
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   828
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   829
! !
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   830
5471
a57eeb01c5ab General encoding method (#encodeOn:with:)
Stefan Vogel <sv@exept.de>
parents: 5390
diff changeset
   831
!AbsoluteTime methodsFor:'encoding'!
a57eeb01c5ab General encoding method (#encodeOn:with:)
Stefan Vogel <sv@exept.de>
parents: 5390
diff changeset
   832
a57eeb01c5ab General encoding method (#encodeOn:with:)
Stefan Vogel <sv@exept.de>
parents: 5390
diff changeset
   833
encodeOn:anEncoder with:aParameter
a57eeb01c5ab General encoding method (#encodeOn:with:)
Stefan Vogel <sv@exept.de>
parents: 5390
diff changeset
   834
a57eeb01c5ab General encoding method (#encodeOn:with:)
Stefan Vogel <sv@exept.de>
parents: 5390
diff changeset
   835
    anEncoder encodeAbsoluteTime:self with:aParameter
a57eeb01c5ab General encoding method (#encodeOn:with:)
Stefan Vogel <sv@exept.de>
parents: 5390
diff changeset
   836
a57eeb01c5ab General encoding method (#encodeOn:with:)
Stefan Vogel <sv@exept.de>
parents: 5390
diff changeset
   837
a57eeb01c5ab General encoding method (#encodeOn:with:)
Stefan Vogel <sv@exept.de>
parents: 5390
diff changeset
   838
! !
a57eeb01c5ab General encoding method (#encodeOn:with:)
Stefan Vogel <sv@exept.de>
parents: 5390
diff changeset
   839
5677
52bd6bf1775f us/non-us format reading ($/ as separator: us-format)
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
   840
213
3b56a17534fd *** empty log message ***
claus
parents: 154
diff changeset
   841
!AbsoluteTime methodsFor:'printing & storing'!
30
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
   842
4843
3a4484b834dd better printing
Claus Gittinger <cg@exept.de>
parents: 4839
diff changeset
   843
addPrintBindingsTo:dict
4930
edb87412f76d month vs. mon in formatString
Claus Gittinger <cg@exept.de>
parents: 4906
diff changeset
   844
    |d m y s|
4843
3a4484b834dd better printing
Claus Gittinger <cg@exept.de>
parents: 4839
diff changeset
   845
3a4484b834dd better printing
Claus Gittinger <cg@exept.de>
parents: 4839
diff changeset
   846
    OperatingSystem computeDatePartsOf:osTime for:[
3a4484b834dd better printing
Claus Gittinger <cg@exept.de>
parents: 4839
diff changeset
   847
        :year :month :day | d := day. m := month. y := year.
3a4484b834dd better printing
Claus Gittinger <cg@exept.de>
parents: 4839
diff changeset
   848
    ].
3a4484b834dd better printing
Claus Gittinger <cg@exept.de>
parents: 4839
diff changeset
   849
    super addPrintBindingsTo:dict.
3a4484b834dd better printing
Claus Gittinger <cg@exept.de>
parents: 4839
diff changeset
   850
    dict at:#day put:(d printString leftPaddedTo:2 with:$0).
3a4484b834dd better printing
Claus Gittinger <cg@exept.de>
parents: 4839
diff changeset
   851
    dict at:#dayInWeek put:(self dayInWeek).
4930
edb87412f76d month vs. mon in formatString
Claus Gittinger <cg@exept.de>
parents: 4906
diff changeset
   852
    dict at:#month put:(s := m printString leftPaddedTo:2 with:$0).
edb87412f76d month vs. mon in formatString
Claus Gittinger <cg@exept.de>
parents: 4906
diff changeset
   853
    dict at:#mon put:s.   "/ for backward compatibility only
4843
3a4484b834dd better printing
Claus Gittinger <cg@exept.de>
parents: 4839
diff changeset
   854
    dict at:#year put:(y printString leftPaddedTo:4 with:$0).
3a4484b834dd better printing
Claus Gittinger <cg@exept.de>
parents: 4839
diff changeset
   855
3a4484b834dd better printing
Claus Gittinger <cg@exept.de>
parents: 4839
diff changeset
   856
    dict at:#Day put:d printString.
4930
edb87412f76d month vs. mon in formatString
Claus Gittinger <cg@exept.de>
parents: 4906
diff changeset
   857
    dict at:#Month put:(s := m printString).
edb87412f76d month vs. mon in formatString
Claus Gittinger <cg@exept.de>
parents: 4906
diff changeset
   858
    dict at:#Mon put:s.   "/ for backward compatibility only
4843
3a4484b834dd better printing
Claus Gittinger <cg@exept.de>
parents: 4839
diff changeset
   859
3a4484b834dd better printing
Claus Gittinger <cg@exept.de>
parents: 4839
diff changeset
   860
    "
4930
edb87412f76d month vs. mon in formatString
Claus Gittinger <cg@exept.de>
parents: 4906
diff changeset
   861
     AbsoluteTime now printOn:Transcript format:'%(day):%(month)'. Transcript cr.      
4843
3a4484b834dd better printing
Claus Gittinger <cg@exept.de>
parents: 4839
diff changeset
   862
     AbsoluteTime now printOn:Transcript format:'%(dayInWeek)'. Transcript cr.      
4930
edb87412f76d month vs. mon in formatString
Claus Gittinger <cg@exept.de>
parents: 4906
diff changeset
   863
     AbsoluteTime now printOn:Transcript format:'%(Day)-%(month)-%(year) %h:%m:%s.%i'. Transcript cr.      
4843
3a4484b834dd better printing
Claus Gittinger <cg@exept.de>
parents: 4839
diff changeset
   864
     AbsoluteTime now printOn:Transcript. Transcript cr
3a4484b834dd better printing
Claus Gittinger <cg@exept.de>
parents: 4839
diff changeset
   865
    "
3a4484b834dd better printing
Claus Gittinger <cg@exept.de>
parents: 4839
diff changeset
   866
3a4484b834dd better printing
Claus Gittinger <cg@exept.de>
parents: 4839
diff changeset
   867
3a4484b834dd better printing
Claus Gittinger <cg@exept.de>
parents: 4839
diff changeset
   868
3a4484b834dd better printing
Claus Gittinger <cg@exept.de>
parents: 4839
diff changeset
   869
!
3a4484b834dd better printing
Claus Gittinger <cg@exept.de>
parents: 4839
diff changeset
   870
5379
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   871
printGeneralizedOn:aStream 
5290
f26854f0f074 Add #printGeneralizedOn:
Stefan Vogel <sv@exept.de>
parents: 4930
diff changeset
   872
    "append a representation of the receiver to aStream in a general format,
f26854f0f074 Add #printGeneralizedOn:
Stefan Vogel <sv@exept.de>
parents: 4930
diff changeset
   873
     top-down, without separtors: 'yyyymmddHHMMSS.mmm+0100'
f26854f0f074 Add #printGeneralizedOn:
Stefan Vogel <sv@exept.de>
parents: 4930
diff changeset
   874
     This format is used for the ASN.1 GeneralizedTime as defined in X.208 Sec. 33,
f26854f0f074 Add #printGeneralizedOn:
Stefan Vogel <sv@exept.de>
parents: 4930
diff changeset
   875
     so read this before changing the output format."
f26854f0f074 Add #printGeneralizedOn:
Stefan Vogel <sv@exept.de>
parents: 4930
diff changeset
   876
5379
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   877
    ^ self printGeneralizedOn:aStream isLocal:false.
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   878
!
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   879
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   880
printGeneralizedOn:aStream isLocal:isLocal
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   881
    "append a representation of the receiver to aStream in a general format,
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   882
     top-down, without separtors: 'yyyymmddHHMMSS.mmm+0100'
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   883
     This format is used for the ASN.1 GeneralizedTime as defined in X.208 Sec. 33,
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   884
     so read this before changing the output format.
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   885
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   886
     If isLocal is true, represent as local time, otherwise add UTC time offset."
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   887
5290
f26854f0f074 Add #printGeneralizedOn:
Stefan Vogel <sv@exept.de>
parents: 4930
diff changeset
   888
    |t off|
f26854f0f074 Add #printGeneralizedOn:
Stefan Vogel <sv@exept.de>
parents: 4930
diff changeset
   889
f26854f0f074 Add #printGeneralizedOn:
Stefan Vogel <sv@exept.de>
parents: 4930
diff changeset
   890
    t := OperatingSystem computeTimeAndDateFrom:osTime.
f26854f0f074 Add #printGeneralizedOn:
Stefan Vogel <sv@exept.de>
parents: 4930
diff changeset
   891
f26854f0f074 Add #printGeneralizedOn:
Stefan Vogel <sv@exept.de>
parents: 4930
diff changeset
   892
    (t at:1) printOn:aStream leftPaddedTo:4 with:$0.
f26854f0f074 Add #printGeneralizedOn:
Stefan Vogel <sv@exept.de>
parents: 4930
diff changeset
   893
    (t at:2) printOn:aStream leftPaddedTo:2 with:$0.
f26854f0f074 Add #printGeneralizedOn:
Stefan Vogel <sv@exept.de>
parents: 4930
diff changeset
   894
    (t at:3) printOn:aStream leftPaddedTo:2 with:$0.
f26854f0f074 Add #printGeneralizedOn:
Stefan Vogel <sv@exept.de>
parents: 4930
diff changeset
   895
    (t at:4) printOn:aStream leftPaddedTo:2 with:$0. 
f26854f0f074 Add #printGeneralizedOn:
Stefan Vogel <sv@exept.de>
parents: 4930
diff changeset
   896
    (t at:5) printOn:aStream leftPaddedTo:2 with:$0.
f26854f0f074 Add #printGeneralizedOn:
Stefan Vogel <sv@exept.de>
parents: 4930
diff changeset
   897
    (t at:6) printOn:aStream leftPaddedTo:2 with:$0.
f26854f0f074 Add #printGeneralizedOn:
Stefan Vogel <sv@exept.de>
parents: 4930
diff changeset
   898
    aStream nextPut:$..
f26854f0f074 Add #printGeneralizedOn:
Stefan Vogel <sv@exept.de>
parents: 4930
diff changeset
   899
    (t at:9) printOn:aStream leftPaddedTo:3 with:$0.
f26854f0f074 Add #printGeneralizedOn:
Stefan Vogel <sv@exept.de>
parents: 4930
diff changeset
   900
5379
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   901
    isLocal ifFalse:[
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   902
        "/ this should be printed as non-local-time
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   903
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   904
        off := t at:7.
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   905
        off == 0 ifTrue:[
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   906
            aStream nextPut:$Z.
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   907
        ] ifFalse:[ |min|
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   908
            off < 0 ifTrue:[
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   909
                aStream nextPut:$+.
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   910
                off := off negated.
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   911
            ] ifFalse:[
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   912
                aStream nextPut:$-.
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   913
            ].
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   914
            min := off // 60.
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   915
            min // 60 printOn:aStream leftPaddedTo:2 with:$0.
2cf681402817 Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents: 5376
diff changeset
   916
            min \\ 60 printOn:aStream leftPaddedTo:2 with:$0.
5290
f26854f0f074 Add #printGeneralizedOn:
Stefan Vogel <sv@exept.de>
parents: 4930
diff changeset
   917
        ].
f26854f0f074 Add #printGeneralizedOn:
Stefan Vogel <sv@exept.de>
parents: 4930
diff changeset
   918
    ].
f26854f0f074 Add #printGeneralizedOn:
Stefan Vogel <sv@exept.de>
parents: 4930
diff changeset
   919
f26854f0f074 Add #printGeneralizedOn:
Stefan Vogel <sv@exept.de>
parents: 4930
diff changeset
   920
f26854f0f074 Add #printGeneralizedOn:
Stefan Vogel <sv@exept.de>
parents: 4930
diff changeset
   921
    "
5291
8b1013528fb4 Add #printGeneralizedOn:
Stefan Vogel <sv@exept.de>
parents: 5290
diff changeset
   922
     AbsoluteTime now printGeneralizedOn:Transcript. Transcript cr. 
8b1013528fb4 Add #printGeneralizedOn:
Stefan Vogel <sv@exept.de>
parents: 5290
diff changeset
   923
     (AbsoluteTime fromSeconds:0) printGeneralizedOn:Transcript. Transcript cr.
5290
f26854f0f074 Add #printGeneralizedOn:
Stefan Vogel <sv@exept.de>
parents: 4930
diff changeset
   924
     Time now printOn:Transcript. Transcript cr.           
f26854f0f074 Add #printGeneralizedOn:
Stefan Vogel <sv@exept.de>
parents: 4930
diff changeset
   925
     Date today printOn:Transcript. Transcript cr.        
f26854f0f074 Add #printGeneralizedOn:
Stefan Vogel <sv@exept.de>
parents: 4930
diff changeset
   926
5291
8b1013528fb4 Add #printGeneralizedOn:
Stefan Vogel <sv@exept.de>
parents: 5290
diff changeset
   927
     Time now asAbsoluteTime printGeneralizedOn:Transcript. Transcript cr.           
8b1013528fb4 Add #printGeneralizedOn:
Stefan Vogel <sv@exept.de>
parents: 5290
diff changeset
   928
     AbsoluteTime now printGeneralizedOn:Transcript. Transcript cr. 
5290
f26854f0f074 Add #printGeneralizedOn:
Stefan Vogel <sv@exept.de>
parents: 4930
diff changeset
   929
5291
8b1013528fb4 Add #printGeneralizedOn:
Stefan Vogel <sv@exept.de>
parents: 5290
diff changeset
   930
     Date today asAbsoluteTime printGeneralizedOn:Transcript. Transcript cr.           
5290
f26854f0f074 Add #printGeneralizedOn:
Stefan Vogel <sv@exept.de>
parents: 4930
diff changeset
   931
     Date today printOn:Transcript. Transcript cr.           
f26854f0f074 Add #printGeneralizedOn:
Stefan Vogel <sv@exept.de>
parents: 4930
diff changeset
   932
    "
f26854f0f074 Add #printGeneralizedOn:
Stefan Vogel <sv@exept.de>
parents: 4930
diff changeset
   933
f26854f0f074 Add #printGeneralizedOn:
Stefan Vogel <sv@exept.de>
parents: 4930
diff changeset
   934
    "Modified: / 1.7.1996 / 15:20:59 / cg"
f26854f0f074 Add #printGeneralizedOn:
Stefan Vogel <sv@exept.de>
parents: 4930
diff changeset
   935
    "Modified: / 17.1.2000 / 15:53:02 / stefan"
f26854f0f074 Add #printGeneralizedOn:
Stefan Vogel <sv@exept.de>
parents: 4930
diff changeset
   936
!
f26854f0f074 Add #printGeneralizedOn:
Stefan Vogel <sv@exept.de>
parents: 4930
diff changeset
   937
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   938
printOn:aStream
275
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   939
    "append a user readable representation of the receiver to aStream.
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   940
     The format is compatible with readFromString:, but not with readFrom:."
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   941
4843
3a4484b834dd better printing
Claus Gittinger <cg@exept.de>
parents: 4839
diff changeset
   942
    self printOn:aStream format:'%(Day)-%(mon)-%(year) %h:%m:%s.%i'  
92
0c73b48551ac *** empty log message ***
claus
parents: 82
diff changeset
   943
0c73b48551ac *** empty log message ***
claus
parents: 82
diff changeset
   944
    "
275
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   945
     AbsoluteTime now printOn:Transcript. Transcript cr. 
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   946
     (AbsoluteTime fromSeconds:0) printOn:Transcript. Transcript cr.
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   947
     Time now printOn:Transcript. Transcript cr.           
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   948
     Date today printOn:Transcript. Transcript cr.        
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   949
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   950
     Time now asAbsoluteTime printOn:Transcript. Transcript cr.           
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   951
     AbsoluteTime now printOn:Transcript. Transcript cr. 
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   952
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   953
     Date today asAbsoluteTime printOn:Transcript. Transcript cr.           
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   954
     Date today printOn:Transcript. Transcript cr.           
92
0c73b48551ac *** empty log message ***
claus
parents: 82
diff changeset
   955
    "
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   956
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   957
    "Modified: 1.7.1996 / 15:20:59 / cg"
30
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
   958
!
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
   959
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   960
storeOn:aStream
275
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   961
    "store the receiver in a format suitable for reconstruction of the
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   962
     receiver via readFrom:"
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   963
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   964
    aStream nextPut:$(; 
242
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   965
	    nextPutAll:self class name; 
275
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   966
	    nextPutAll:' new setSeconds:'.
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   967
    self getSeconds storeOn:aStream.
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   968
    aStream nextPut:$).
54
06dbdeeed4f9 *** empty log message ***
claus
parents: 30
diff changeset
   969
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   970
    "
275
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   971
     AbsoluteTime now storeString 
30
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
   972
275
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   973
     AbsoluteTime readFrom:(AbsoluteTime now storeString) readStream
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   974
    "
30
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
   975
! !
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   976
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   977
!AbsoluteTime methodsFor:'private'!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   978
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   979
fromOSTime:anUninterpretedOSTime
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   980
    "strictly private: set the seconds from an OS time (since whatever)"
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   981
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   982
    osTime := anUninterpretedOSTime
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   983
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   984
    "Created: 1.7.1996 / 14:33:21 / cg"
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   985
!
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   986
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   987
getMilliseconds
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   988
    "strictly private: return the milliseconds (since whatever)"
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   989
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   990
    ^ osTime
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   991
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   992
    "Created: 1.7.1996 / 14:33:56 / cg"
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   993
!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   994
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   995
getSeconds
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   996
    "strictly private: return the seconds (since whatever)"
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   997
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   998
    ^ osTime // 1000
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   999
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
  1000
    "Modified: 1.7.1996 / 14:33:44 / cg"
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
  1001
!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
  1002
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
  1003
setMilliseconds:millis
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
  1004
    "strictly private: set the milliseconds (since whatever)"
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
  1005
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
  1006
    osTime := millis.
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
  1007
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
  1008
    "Modified: 20.12.1995 / 11:46:36 / stefan"
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
  1009
    "Created: 1.7.1996 / 14:34:24 / cg"
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
  1010
!
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
  1011
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
  1012
setSeconds:secs
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
  1013
    "strictly private: set the seconds (since whatever)"
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
  1014
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
  1015
    osTime := secs * 1000.
795
ff477bad0f2d fix setSeconds:
Stefan Vogel <sv@exept.de>
parents: 699
diff changeset
  1016
ff477bad0f2d fix setSeconds:
Stefan Vogel <sv@exept.de>
parents: 699
diff changeset
  1017
    "Modified: 20.12.1995 / 11:46:36 / stefan"
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
  1018
    "Modified: 1.7.1996 / 14:34:10 / cg"
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
  1019
! !
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
  1020
2311
88b035dd471a New Method: #secondsSince1970.
Stefan Vogel <sv@exept.de>
parents: 1701
diff changeset
  1021
!AbsoluteTime class methodsFor:'documentation'!
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
  1022
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
  1023
version
5677
52bd6bf1775f us/non-us format reading ($/ as separator: us-format)
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  1024
    ^ '$Header: /cvs/stx/stx/libbasic/Timestamp.st,v 1.56 2000-10-25 09:18:46 cg Exp $'
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
  1025
! !