AbsTime.st
author Claus Gittinger <cg@exept.de>
Fri, 18 Apr 1997 21:05:22 +0200
changeset 2568 9b7a3a08b8ca
parent 2311 88b035dd471a
child 2623 593ab389efd1
permissions -rw-r--r--
added #rootsOfTheWorld for ST-80 compatibility
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
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
    13
AbstractTime subclass:#AbsoluteTime
795
ff477bad0f2d fix setSeconds:
Stefan Vogel <sv@exept.de>
parents: 699
diff changeset
    14
	instanceVariableNames:'osTime'
ff477bad0f2d fix setSeconds:
Stefan Vogel <sv@exept.de>
parents: 699
diff changeset
    15
	classVariableNames:''
ff477bad0f2d fix setSeconds:
Stefan Vogel <sv@exept.de>
parents: 699
diff changeset
    16
	poolDictionaries:''
ff477bad0f2d fix setSeconds:
Stefan Vogel <sv@exept.de>
parents: 699
diff changeset
    17
	category:'Magnitude-General'
30
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
    18
!
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
    19
2311
88b035dd471a New Method: #secondsSince1970.
Stefan Vogel <sv@exept.de>
parents: 1701
diff changeset
    20
!AbsoluteTime class methodsFor:'documentation'!
30
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
    21
82
0147b4f725ae *** empty log message ***
claus
parents: 77
diff changeset
    22
copyright
0147b4f725ae *** empty log message ***
claus
parents: 77
diff changeset
    23
"
0147b4f725ae *** empty log message ***
claus
parents: 77
diff changeset
    24
 COPYRIGHT (c) 1989 by Claus Gittinger
154
d4236ec280a6 *** empty log message ***
claus
parents: 92
diff changeset
    25
	      All Rights Reserved
82
0147b4f725ae *** empty log message ***
claus
parents: 77
diff changeset
    26
0147b4f725ae *** empty log message ***
claus
parents: 77
diff changeset
    27
 This software is furnished under a license and may be used
0147b4f725ae *** empty log message ***
claus
parents: 77
diff changeset
    28
 only in accordance with the terms of that license and with the
0147b4f725ae *** empty log message ***
claus
parents: 77
diff changeset
    29
 inclusion of the above copyright notice.   This software may not
0147b4f725ae *** empty log message ***
claus
parents: 77
diff changeset
    30
 be provided or otherwise made available to, or used by, any
0147b4f725ae *** empty log message ***
claus
parents: 77
diff changeset
    31
 other person.  No title to or ownership of the software is
0147b4f725ae *** empty log message ***
claus
parents: 77
diff changeset
    32
 hereby transferred.
0147b4f725ae *** empty log message ***
claus
parents: 77
diff changeset
    33
"
0147b4f725ae *** empty log message ***
claus
parents: 77
diff changeset
    34
!
0147b4f725ae *** empty log message ***
claus
parents: 77
diff changeset
    35
30
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
    36
documentation
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
    37
"
1669
4951596746f7 comments & code cleanup
Claus Gittinger <cg@exept.de>
parents: 1521
diff changeset
    38
    This class represents absolute time values in milliSeconds starting some
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
    39
    time in the past. 
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
    40
    (typically, from 1st. Jan 1970, as used in the Unix operating system,
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
    41
     but other systems may bias the time differently.
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
    42
     Actually, the implementation does not depend or even know which time/date 
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
    43
     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
    44
     as return from the OS.
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
    45
     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
    46
     how to convert these times.
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
    47
     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
    48
     time or last-modifiaction-time) can be handled transparent to other
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
    49
     times - especially comparisons).
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
    50
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
    51
    You should not interpret the osTime instance variable directly, instead
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
    52
    (if at all), as the OS to convert.
30
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
    53
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
    54
    Its implementation is not the same as in ST-80 
1669
4951596746f7 comments & code cleanup
Claus Gittinger <cg@exept.de>
parents: 1521
diff changeset
    55
    (which represents Time as seconds from 1. Jan 1901.)
30
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
    56
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
    57
    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
    58
    time within one day). 
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
    59
    Time instances cannot be used to compare times across midnight; 
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
    60
    instances of AbsoluteTime can.
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
    61
1306
c0189edbd96c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1282
diff changeset
    62
    [author:]
c0189edbd96c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1282
diff changeset
    63
        Claus Gittinger
c0189edbd96c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1282
diff changeset
    64
1282
3f5eda57c516 commentary
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
    65
    [See also:]
3f5eda57c516 commentary
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
    66
        Time Date
3f5eda57c516 commentary
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
    67
        Delay ProcessorScheduler
30
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
    68
"
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
    69
! !
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
    70
2311
88b035dd471a New Method: #secondsSince1970.
Stefan Vogel <sv@exept.de>
parents: 1701
diff changeset
    71
!AbsoluteTime class methodsFor:'instance creation'!
30
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
    72
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
    73
day:d month:m year:y hour:h minutes:min seconds:s
1228
127d990e2f77 commentary
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
    74
    "return an instance of the receiver, given individual components.
127d990e2f77 commentary
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
    75
     See also `AbsoluteTime now' and other protocol inherited
127d990e2f77 commentary
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
    76
     from my superclass."
30
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
    77
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
    78
    ^ self 
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
    79
        day:d month:m year:y hour:h 
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
    80
        minutes:min seconds:s milliseconds:0
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
    81
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
    82
    "
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
    83
     AbsoluteTime day:2 month:1 year:1991 hour:12 minutes:30 seconds:0 
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
    84
     AbsoluteTime day:8 month:1 year:1995 hour:0 minutes:43 seconds:48 
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
    85
    "
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
    86
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
    87
    "Modified: 1.7.1996 / 15:22:26 / cg"
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
    88
!
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
    89
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
    90
day:d month:m year:y hour:h minutes:min seconds:s milliseconds:millis
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
    91
    "return an instance of the receiver, given individual components.
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
    92
     See also `AbsoluteTime now' and other protocol inherited
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
    93
     from my superclass."
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
    94
423
claus
parents: 392
diff changeset
    95
    ^ self basicNew 
1228
127d990e2f77 commentary
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
    96
        fromOSTime:(OperatingSystem 
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
    97
                        computeOSTimeFromYear:y month:m day:d 
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
    98
                                         hour:h minute:min seconds:s
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
    99
                                       millis:millis)
30
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
   100
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   101
    "
2311
88b035dd471a New Method: #secondsSince1970.
Stefan Vogel <sv@exept.de>
parents: 1701
diff changeset
   102
     AbsoluteTime day:1 month:1 year:1970 hour:1 minutes:0 seconds:0 
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   103
     AbsoluteTime day:2 month:1 year:1991 hour:12 minutes:30 seconds:0 
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   104
     AbsoluteTime day:2 month:1 year:1991 hour:12 minutes:30 seconds:0 milliseconds:100
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   105
    "
1228
127d990e2f77 commentary
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   106
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   107
    "Created: 1.7.1996 / 14:46:09 / cg"
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   108
    "Modified: 1.7.1996 / 15:22:07 / cg"
2311
88b035dd471a New Method: #secondsSince1970.
Stefan Vogel <sv@exept.de>
parents: 1701
diff changeset
   109
    "Modified: 22.10.1996 / 09:25:04 / stefan"
275
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   110
!
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   111
423
claus
parents: 392
diff changeset
   112
fromDate:aDate andTime:aTime
claus
parents: 392
diff changeset
   113
    "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
   114
     object.
127d990e2f77 commentary
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   115
     See also `AbsoluteTime now' and other protocol inherited
127d990e2f77 commentary
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   116
     from my superclass."
423
claus
parents: 392
diff changeset
   117
claus
parents: 392
diff changeset
   118
    ^ self 
1228
127d990e2f77 commentary
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   119
        day:aDate day 
127d990e2f77 commentary
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   120
        month:aDate month 
127d990e2f77 commentary
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   121
        year:aDate year 
127d990e2f77 commentary
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   122
        hour:aTime hours 
127d990e2f77 commentary
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   123
        minutes:aTime minutes 
127d990e2f77 commentary
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   124
        seconds:aTime seconds 
423
claus
parents: 392
diff changeset
   125
claus
parents: 392
diff changeset
   126
    "
1228
127d990e2f77 commentary
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   127
     AbsoluteTime fromDate:(Date today) andTime:(Time now)  
127d990e2f77 commentary
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   128
     AbsoluteTime fromDate:(Date today plusDays:1) andTime:(Time now) 
127d990e2f77 commentary
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   129
     AbsoluteTime now 
423
claus
parents: 392
diff changeset
   130
    "
claus
parents: 392
diff changeset
   131
claus
parents: 392
diff changeset
   132
    "Modified: 8.9.1995 / 15:07:30 / claus"
1228
127d990e2f77 commentary
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   133
    "Modified: 19.4.1996 / 15:25:46 / cg"
423
claus
parents: 392
diff changeset
   134
!
claus
parents: 392
diff changeset
   135
1513
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   136
newDay:dayInYear year:year
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   137
    "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
   138
     Date protocol compatibility"
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   139
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   140
    ^ (Date newDay:dayInYear year:year) asAbsoluteTime
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   141
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   142
    "
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   143
     AbsoluteTime newDay:183 year:1996
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   144
    "
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   145
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   146
    "Modified: 2.7.1996 / 09:39:30 / cg"
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   147
!
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   148
569
7134eb78cf48 readFrom:onError: can now also read from a string
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   149
readFrom:aStringOrStream onError:exceptionBlock
275
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   150
    "return a new AbsoluteTime, reading a printed representation from aStream.
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   151
     The string is interpreted as 24 hour format, as printed.
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   152
     Notice, that this is not the storeString format and 
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   153
     is different from the format expected by readFrom:."
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   154
1701
80d13adb2e77 better errorHandling in readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   155
    ErrorSignal handle:[:ex |
80d13adb2e77 better errorHandling in readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   156
        ^ exceptionBlock value
80d13adb2e77 better errorHandling in readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   157
    ] do:[
80d13adb2e77 better errorHandling in readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   158
        |str day month year hour min sec millis ex|
275
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   159
1701
80d13adb2e77 better errorHandling in readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   160
        str := aStringOrStream readStream.
80d13adb2e77 better errorHandling in readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   161
80d13adb2e77 better errorHandling in readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   162
        ex := [^ exceptionBlock value].
80d13adb2e77 better errorHandling in readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   163
        day := Integer readFrom:str onError:ex.
80d13adb2e77 better errorHandling in readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   164
        (day between:1 and:31) ifFalse:[^ exceptionBlock value].
275
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   165
1701
80d13adb2e77 better errorHandling in readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   166
        [str peek isDigit] whileFalse:[str next].
80d13adb2e77 better errorHandling in readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   167
        month := Integer readFrom:str onError:ex.
80d13adb2e77 better errorHandling in readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   168
        (month between:1 and:12) ifFalse:[^ exceptionBlock value].
275
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   169
1701
80d13adb2e77 better errorHandling in readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   170
        [str peek isDigit] whileFalse:[str next].
80d13adb2e77 better errorHandling in readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   171
        year := Integer readFrom:str onError:ex.
275
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   172
1701
80d13adb2e77 better errorHandling in readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   173
        [str peek isDigit] whileFalse:[str next].
80d13adb2e77 better errorHandling in readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   174
        hour := Integer readFrom:str onError:ex.
80d13adb2e77 better errorHandling in readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   175
        (hour between:0 and:24) ifFalse:[^ exceptionBlock value].
275
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   176
1701
80d13adb2e77 better errorHandling in readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   177
        [str peek isDigit] whileFalse:[str next].
80d13adb2e77 better errorHandling in readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   178
        min := Integer readFrom:str onError:ex.
80d13adb2e77 better errorHandling in readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   179
        (min between:0 and:59) ifFalse:[^ exceptionBlock value].
275
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   180
1701
80d13adb2e77 better errorHandling in readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   181
        [str peek isDigit] whileFalse:[str next].
80d13adb2e77 better errorHandling in readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   182
        sec := Integer readFrom:str onError:ex.
80d13adb2e77 better errorHandling in readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   183
        (sec between:0 and:59) ifFalse:[^ exceptionBlock value].
275
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   184
1701
80d13adb2e77 better errorHandling in readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   185
        str peek = '.' ifTrue:[
80d13adb2e77 better errorHandling in readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   186
            str next.
80d13adb2e77 better errorHandling in readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   187
            millis := Integer readFrom:str onError:ex.
80d13adb2e77 better errorHandling in readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   188
        ] ifFalse:[
80d13adb2e77 better errorHandling in readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   189
            millis := 0.
80d13adb2e77 better errorHandling in readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   190
        ].
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   191
1701
80d13adb2e77 better errorHandling in readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   192
        "special check"
80d13adb2e77 better errorHandling in readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   193
        hour == 24 ifTrue:[
80d13adb2e77 better errorHandling in readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   194
            (min ~~ 0 or:[sec ~~ 0]) ifTrue:[^ exceptionBlock value].
80d13adb2e77 better errorHandling in readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   195
        ].
80d13adb2e77 better errorHandling in readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   196
80d13adb2e77 better errorHandling in readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   197
        ^ self day:day month:month year:year hour:hour minutes:min seconds:sec
275
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   198
    ].
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   199
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   200
    "
569
7134eb78cf48 readFrom:onError: can now also read from a string
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   201
     AbsoluteTime readFrom:'20-2-1995 13:11:06'    
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   202
     AbsoluteTime readFrom:'20-2-1995 13:11:06.100'    
275
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   203
    "
569
7134eb78cf48 readFrom:onError: can now also read from a string
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   204
1701
80d13adb2e77 better errorHandling in readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   205
    "Modified: 8.10.1996 / 19:25:59 / cg"
2311
88b035dd471a New Method: #secondsSince1970.
Stefan Vogel <sv@exept.de>
parents: 1701
diff changeset
   206
!
88b035dd471a New Method: #secondsSince1970.
Stefan Vogel <sv@exept.de>
parents: 1701
diff changeset
   207
88b035dd471a New Method: #secondsSince1970.
Stefan Vogel <sv@exept.de>
parents: 1701
diff changeset
   208
secondsSince1970:sec
88b035dd471a New Method: #secondsSince1970.
Stefan Vogel <sv@exept.de>
parents: 1701
diff changeset
   209
    "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
   210
     This is the format used in the UNIX world"
88b035dd471a New Method: #secondsSince1970.
Stefan Vogel <sv@exept.de>
parents: 1701
diff changeset
   211
88b035dd471a New Method: #secondsSince1970.
Stefan Vogel <sv@exept.de>
parents: 1701
diff changeset
   212
    ^ self day:1 month:1 year:1970 hour:0 minutes:0 seconds:sec.
88b035dd471a New Method: #secondsSince1970.
Stefan Vogel <sv@exept.de>
parents: 1701
diff changeset
   213
88b035dd471a New Method: #secondsSince1970.
Stefan Vogel <sv@exept.de>
parents: 1701
diff changeset
   214
    "
88b035dd471a New Method: #secondsSince1970.
Stefan Vogel <sv@exept.de>
parents: 1701
diff changeset
   215
        AbsoluteTime secondsSince1970:0
88b035dd471a New Method: #secondsSince1970.
Stefan Vogel <sv@exept.de>
parents: 1701
diff changeset
   216
        AbsoluteTime secondsSince1970:3600
88b035dd471a New Method: #secondsSince1970.
Stefan Vogel <sv@exept.de>
parents: 1701
diff changeset
   217
    "
88b035dd471a New Method: #secondsSince1970.
Stefan Vogel <sv@exept.de>
parents: 1701
diff changeset
   218
88b035dd471a New Method: #secondsSince1970.
Stefan Vogel <sv@exept.de>
parents: 1701
diff changeset
   219
    "Created: 21.10.1996 / 17:48:30 / stefan"
88b035dd471a New Method: #secondsSince1970.
Stefan Vogel <sv@exept.de>
parents: 1701
diff changeset
   220
    "Modified: 22.10.1996 / 11:07:45 / stefan"
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   221
! !
30
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
   222
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
   223
!AbsoluteTime methodsFor:'accessing'!
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
   224
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
   225
day
92
0c73b48551ac *** empty log message ***
claus
parents: 82
diff changeset
   226
    "return the day-in-month of the receiver (1..31).
275
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   227
     For compatibility, use instances of Date for this."
30
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
   228
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   229
    |d|
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   230
275
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   231
    OperatingSystem computeDatePartsOf:osTime for:[:year :month :day |
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   232
        d := day
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   233
    ].
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   234
    ^ d
54
06dbdeeed4f9 *** empty log message ***
claus
parents: 30
diff changeset
   235
92
0c73b48551ac *** empty log message ***
claus
parents: 82
diff changeset
   236
    "
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   237
     AbsoluteTime now day 
92
0c73b48551ac *** empty log message ***
claus
parents: 82
diff changeset
   238
    "
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   239
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   240
    "Modified: 1.7.1996 / 15:23:02 / cg"
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   241
!
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   242
1513
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   243
dayInWeek
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   244
    "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
   245
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   246
    |info|
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   247
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   248
    info := OperatingSystem computeTimeAndDateFrom:osTime.
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   249
    ^ info at:11
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   250
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   251
    "
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   252
     AbsoluteTime now dayInWeek 
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   253
    "
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   254
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   255
    "Modified: 2.7.1996 / 09:20:32 / cg"
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   256
    "Created: 2.7.1996 / 09:35:48 / cg"
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   257
!
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   258
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   259
dayInYear
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   260
    "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
   261
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   262
    |info|
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   263
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   264
    info := OperatingSystem computeTimeAndDateFrom:osTime.
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   265
    ^ info at:10
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
    "
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   268
     AbsoluteTime now dayInYear  
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   269
     AbsoluteTime newDay:184 year:1996  
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   270
    "
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
    "Modified: 2.7.1996 / 10:21:02 / cg"
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   273
!
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   274
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   275
hour
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   276
    "return the hour (0..23).
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   277
     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
   278
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   279
    ^ self hours
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   280
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   281
    "Created: 1.7.1996 / 15:14:50 / cg"
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   282
    "Modified: 1.7.1996 / 15:15:32 / cg"
30
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
   283
!
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
   284
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   285
hours
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   286
    "return the hours (0..23)"
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   287
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   288
    |hr|
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   289
1513
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   290
    OperatingSystem computeTimePartsOf:osTime for:[:hours :minutes :secs :millis |
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   291
        hr := hours
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   292
    ].
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   293
    ^ hr
54
06dbdeeed4f9 *** empty log message ***
claus
parents: 30
diff changeset
   294
92
0c73b48551ac *** empty log message ***
claus
parents: 82
diff changeset
   295
    "
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   296
     AbsoluteTime now hours 
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   297
    "
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   298
1513
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   299
    "Modified: 2.7.1996 / 09:20:32 / cg"
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   300
!
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   301
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   302
millisecond
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   303
    "return the millisecond (0..999).
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   304
     ST-80 Timestamp compatibility (I'd prefer the name #milliseconds)."
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   305
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   306
    ^ self milliseconds
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   307
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   308
    "Created: 1.7.1996 / 15:14:50 / cg"
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   309
    "Modified: 1.7.1996 / 15:15:24 / cg"
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   310
!
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   311
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   312
milliseconds
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   313
    "return the milliseconds (0..999)"
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   314
1513
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   315
    |m|
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   316
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   317
    OperatingSystem computeTimePartsOf:osTime for:[:hours :minutes :secs :millis |
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   318
        m := millis
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   319
    ].
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   320
    ^ m
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   321
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   322
    "
1513
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   323
     AbsoluteTime now milliseconds   
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   324
    "
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   325
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   326
    "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
   327
    "Modified: 2.7.1996 / 09:21:41 / cg"
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   328
!
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   329
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   330
minute
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   331
    "return the minute (0..59).
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   332
     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
   333
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   334
    ^ self minutes
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   335
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   336
    "Created: 1.7.1996 / 15:14:29 / cg"
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   337
    "Modified: 1.7.1996 / 15:15:37 / cg"
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   338
!
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   339
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   340
minutes
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   341
    "return the minutes (0..59)"
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   342
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   343
    |m|
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   344
1513
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   345
    OperatingSystem computeTimePartsOf:osTime for:[:hours :minutes :secs :millis |
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   346
        m := minutes
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   347
    ].
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   348
    ^ m
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   349
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   350
    "
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   351
     AbsoluteTime now minutes 
92
0c73b48551ac *** empty log message ***
claus
parents: 82
diff changeset
   352
    "
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   353
1513
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   354
    "Modified: 2.7.1996 / 09:20:49 / cg"
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   355
!
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   356
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   357
month
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   358
    "return the month of the receiver (1..12).
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   359
     For compatibility, use instances of Date for this."
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   360
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   361
    |m|
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   362
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   363
    OperatingSystem computeDatePartsOf:osTime for:[ :year :month :day |
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   364
        m := month
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   365
    ].
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   366
    ^ m
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   367
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   368
    "
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   369
     AbsoluteTime now month
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   370
    "
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   371
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   372
    "Modified: 1.7.1996 / 15:23:05 / cg"
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   373
!
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   374
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   375
second
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   376
    "return the second (0..59).
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   377
     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
   378
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   379
    ^ self seconds
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   380
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   381
    "Created: 1.7.1996 / 15:14:19 / cg"
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   382
    "Modified: 1.7.1996 / 15:15:49 / cg"
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   383
!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   384
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   385
seconds
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   386
    "return the seconds (0..59)"
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   387
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   388
    |s|
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   389
1513
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   390
    OperatingSystem computeTimePartsOf:osTime for:[:hours :minutes :secs :millis |
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   391
        s := secs
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   392
    ].
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   393
    ^ s
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   394
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   395
    "
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   396
     AbsoluteTime now seconds 
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   397
    "
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   398
1513
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   399
    "Modified: 2.7.1996 / 09:20:54 / cg"
92
0c73b48551ac *** empty log message ***
claus
parents: 82
diff changeset
   400
!
0c73b48551ac *** empty log message ***
claus
parents: 82
diff changeset
   401
799
33cf42458eee New Method utcOffset
Stefan Vogel <sv@exept.de>
parents: 795
diff changeset
   402
utcOffset
33cf42458eee New Method utcOffset
Stefan Vogel <sv@exept.de>
parents: 795
diff changeset
   403
    "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
   404
     if daylight saving time applies to ourself, take that into account.
33cf42458eee New Method utcOffset
Stefan Vogel <sv@exept.de>
parents: 795
diff changeset
   405
     Add utcOffset bevor converting to get UTC-Time resp. UTC-Date.
33cf42458eee New Method utcOffset
Stefan Vogel <sv@exept.de>
parents: 795
diff changeset
   406
    "
33cf42458eee New Method utcOffset
Stefan Vogel <sv@exept.de>
parents: 795
diff changeset
   407
33cf42458eee New Method utcOffset
Stefan Vogel <sv@exept.de>
parents: 795
diff changeset
   408
    ^ (OperatingSystem computeTimeAndDateFrom:osTime) at:7
33cf42458eee New Method utcOffset
Stefan Vogel <sv@exept.de>
parents: 795
diff changeset
   409
33cf42458eee New Method utcOffset
Stefan Vogel <sv@exept.de>
parents: 795
diff changeset
   410
    "
33cf42458eee New Method utcOffset
Stefan Vogel <sv@exept.de>
parents: 795
diff changeset
   411
     AbsoluteTime now utcOffset 
33cf42458eee New Method utcOffset
Stefan Vogel <sv@exept.de>
parents: 795
diff changeset
   412
     (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
   413
    "
33cf42458eee New Method utcOffset
Stefan Vogel <sv@exept.de>
parents: 795
diff changeset
   414
33cf42458eee New Method utcOffset
Stefan Vogel <sv@exept.de>
parents: 795
diff changeset
   415
    "Modified: 20.12.1995 / 17:28:49 / stefan"
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   416
    "Modified: 1.7.1996 / 15:21:29 / cg"
799
33cf42458eee New Method utcOffset
Stefan Vogel <sv@exept.de>
parents: 795
diff changeset
   417
!
33cf42458eee New Method utcOffset
Stefan Vogel <sv@exept.de>
parents: 795
diff changeset
   418
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   419
year
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   420
    "return the year of the receiver i.e. 1992.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   421
     For compatibility, use instances of Date for this."
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   422
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   423
    |y|
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   424
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   425
    OperatingSystem computeDatePartsOf:osTime for:[:year :month :day |
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   426
        y := year
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   427
    ].
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   428
    ^ y
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   429
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   430
    "
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   431
     AbsoluteTime now year
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   432
    "
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   433
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   434
    "Modified: 1.7.1996 / 15:23:08 / cg"
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   435
! !
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   436
30
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
   437
!AbsoluteTime methodsFor:'arithmetic'!
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
   438
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
   439
- aTime
242
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   440
    "return the delta in seconds between 2 times."
30
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
   441
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
   442
    ^ self getSeconds - (aTime getSeconds)
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
   443
!
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
   444
242
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   445
addDays:numberOfDays
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   446
    "return a new instance of myself, numberOfDays afterwards."
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   447
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   448
    ^ self addSeconds:(numberOfDays * (60 * 60 * 24))
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   449
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   450
    "
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   451
     |t|
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   452
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   453
     t := AbsoluteTime now.
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   454
     t printNL.
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   455
     (t addDays:7) printNL
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   456
    "
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   457
!
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   458
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   459
subtractDays:numberOfDays
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   460
    "return a new instance of myself, numberOfDays before."
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   461
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   462
    ^ self subtractSeconds:(numberOfDays * (60 * 60 * 24))
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   463
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   464
    "
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   465
     |t|
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   466
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   467
     t := AbsoluteTime now.
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   468
     t printNL.
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   469
     (t subtractDays:50) printNL
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   470
    "
30
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
   471
! !
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
   472
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   473
!AbsoluteTime methodsFor:'comparing'!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   474
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   475
< aTime
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   476
    "return true if the argument, aTime is before the receiver"
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   477
1520
da08f8e49e87 fixed comparing absoluteTimes
Claus Gittinger <cg@exept.de>
parents: 1513
diff changeset
   478
    ^ self getMilliseconds < aTime getMilliseconds
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   479
1520
da08f8e49e87 fixed comparing absoluteTimes
Claus Gittinger <cg@exept.de>
parents: 1513
diff changeset
   480
    "Modified: 3.7.1996 / 13:10:17 / cg"
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   481
!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   482
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   483
= aTime
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   484
    "return true if the argument, aTime represents the same time"
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   485
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   486
    (aTime species == self species) ifFalse:[^ false].
1520
da08f8e49e87 fixed comparing absoluteTimes
Claus Gittinger <cg@exept.de>
parents: 1513
diff changeset
   487
    ^ (self getMilliseconds = aTime getMilliseconds)
da08f8e49e87 fixed comparing absoluteTimes
Claus Gittinger <cg@exept.de>
parents: 1513
diff changeset
   488
da08f8e49e87 fixed comparing absoluteTimes
Claus Gittinger <cg@exept.de>
parents: 1513
diff changeset
   489
    "Modified: 3.7.1996 / 13:10:24 / cg"
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   490
!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   491
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   492
> aTime
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   493
    "return true if the argument, aTime is after the receiver"
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   494
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   495
    ^ self getMilliseconds > aTime getMilliseconds
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   496
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   497
    "Modified: 1.7.1996 / 15:24:38 / cg"
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   498
!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   499
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   500
hash
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   501
    "return an integer useful for hashing on times"
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   502
1520
da08f8e49e87 fixed comparing absoluteTimes
Claus Gittinger <cg@exept.de>
parents: 1513
diff changeset
   503
    ^ osTime // 1000
da08f8e49e87 fixed comparing absoluteTimes
Claus Gittinger <cg@exept.de>
parents: 1513
diff changeset
   504
da08f8e49e87 fixed comparing absoluteTimes
Claus Gittinger <cg@exept.de>
parents: 1513
diff changeset
   505
    "Modified: 3.7.1996 / 13:10:52 / cg"
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   506
! !
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   507
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   508
!AbsoluteTime methodsFor:'converting'!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   509
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   510
asAbsoluteTime
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   511
    "return an AbsoluteTime object from the receiver - thats the receiver."
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   512
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   513
    ^ self
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   514
!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   515
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   516
asDate
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   517
    "return a Date object from the receiver.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   518
     The returned date will only represent the day - not the timeOfDay."
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   519
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   520
    ^ Date fromOSTime:osTime 
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   521
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   522
    "
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   523
     AbsoluteTime now  
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   524
     AbsoluteTime now asDate
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   525
     (AbsoluteTime now addTime:3600) asDate 
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   526
     (AbsoluteTime now addTime:3600) asTime 
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   527
     AbsoluteTime fromSeconds:(AbsoluteTime now asSeconds + 3600) 
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   528
     (AbsoluteTime fromSeconds:(AbsoluteTime now asSeconds + 3600)) asDate  
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   529
    "
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   530
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   531
!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   532
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   533
asSeconds
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   534
    "return the number of seconds elapsed since whatever time the
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   535
     OperatingSystem bases its time upon. Since this is totally
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   536
     OS-dependent, do not interpret the value returned by this method.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   537
     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
   538
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   539
    ^ self getSeconds
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   540
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   541
    "
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   542
     AbsoluteTime now asSeconds
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   543
     AbsoluteTime fromSeconds:(AbsoluteTime now asSeconds + 3600) 
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   544
     Time hour:23 minutes:33 seconds:0         
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   545
     Time fromSeconds:((Time hour:23 minutes:33 seconds:0) asSeconds + 3600) 
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   546
    "
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   547
!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   548
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   549
asTime
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   550
    "return a Time object from the receiver.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   551
     The returned time will only represent the timeOfDay - not the day."
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   552
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   553
    ^ Time fromOSTime:osTime
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   554
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   555
    "
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   556
     AbsoluteTime now  
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   557
     AbsoluteTime now asTime
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   558
     (AbsoluteTime now addTime:3600) asTime 
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   559
    "
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   560
! !
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   561
213
3b56a17534fd *** empty log message ***
claus
parents: 154
diff changeset
   562
!AbsoluteTime methodsFor:'printing & storing'!
30
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
   563
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   564
printOn:aStream
275
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   565
    "append a user readable representation of the receiver to aStream.
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   566
     The format is compatible with readFromString:, but not with readFrom:."
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   567
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   568
    |h min s mil d m y|
30
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
   569
275
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   570
    OperatingSystem computeDatePartsOf:osTime for:[
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   571
        :year :month :day | d := day. m := month. y := year.
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   572
    ].
275
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   573
    OperatingSystem computeTimePartsOf:osTime for:[
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   574
        :hours :minutes :secs :millis | h := hours. min := minutes. s := secs. mil := millis
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   575
    ].
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   576
    d printOn:aStream.
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   577
    aStream nextPut:$-.
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   578
    m printOn:aStream.
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   579
    aStream nextPut:$-.
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   580
    y printOn:aStream.
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   581
    aStream space.
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   582
    h printOn:aStream leftPaddedTo:2 with:$0. 
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   583
    aStream nextPut:$:.
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   584
    min printOn:aStream leftPaddedTo:2 with:$0.
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   585
    aStream nextPut:$:.
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   586
    s printOn:aStream leftPaddedTo:2 with:$0.
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   587
    mil ~~ 0 ifTrue:[
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   588
        aStream nextPut:$..
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   589
        mil printOn:aStream leftPaddedTo:3 with:$0.
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   590
    ].
92
0c73b48551ac *** empty log message ***
claus
parents: 82
diff changeset
   591
0c73b48551ac *** empty log message ***
claus
parents: 82
diff changeset
   592
    "
275
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   593
     AbsoluteTime now printOn:Transcript. Transcript cr. 
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   594
     (AbsoluteTime fromSeconds:0) printOn:Transcript. Transcript cr.
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   595
     Time now printOn:Transcript. Transcript cr.           
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   596
     Date today printOn:Transcript. Transcript cr.        
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   597
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   598
     Time now asAbsoluteTime printOn:Transcript. Transcript cr.           
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   599
     AbsoluteTime now printOn:Transcript. Transcript cr. 
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   600
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   601
     Date today asAbsoluteTime printOn:Transcript. Transcript cr.           
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   602
     Date today printOn:Transcript. Transcript cr.           
92
0c73b48551ac *** empty log message ***
claus
parents: 82
diff changeset
   603
    "
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   604
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   605
    "Modified: 1.7.1996 / 15:20:59 / cg"
30
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
   606
!
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
   607
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   608
storeOn:aStream
275
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   609
    "store the receiver in a format suitable for reconstruction of the
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   610
     receiver via readFrom:"
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   611
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   612
    aStream nextPut:$(; 
242
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   613
	    nextPutAll:self class name; 
275
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   614
	    nextPutAll:' new setSeconds:'.
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   615
    self getSeconds storeOn:aStream.
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   616
    aStream nextPut:$).
54
06dbdeeed4f9 *** empty log message ***
claus
parents: 30
diff changeset
   617
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   618
    "
275
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   619
     AbsoluteTime now storeString 
30
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
   620
275
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   621
     AbsoluteTime readFrom:(AbsoluteTime now storeString) readStream
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   622
    "
30
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
   623
! !
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   624
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   625
!AbsoluteTime methodsFor:'private'!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   626
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   627
fromOSTime:anUninterpretedOSTime
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   628
    "strictly private: set the seconds from an OS time (since whatever)"
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   629
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   630
    osTime := anUninterpretedOSTime
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   631
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   632
    "Created: 1.7.1996 / 14:33:21 / cg"
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   633
!
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   634
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   635
getMilliseconds
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   636
    "strictly private: return the milliseconds (since whatever)"
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   637
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   638
    ^ osTime
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   639
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   640
    "Created: 1.7.1996 / 14:33:56 / cg"
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   641
!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   642
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   643
getSeconds
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   644
    "strictly private: return the seconds (since whatever)"
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   645
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   646
    ^ osTime // 1000
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   647
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   648
    "Modified: 1.7.1996 / 14:33:44 / cg"
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   649
!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   650
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   651
setMilliseconds:millis
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   652
    "strictly private: set the milliseconds (since whatever)"
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   653
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   654
    osTime := millis.
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   655
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   656
    "Modified: 20.12.1995 / 11:46:36 / stefan"
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   657
    "Created: 1.7.1996 / 14:34:24 / cg"
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   658
!
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   659
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   660
setSeconds:secs
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   661
    "strictly private: set the seconds (since whatever)"
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   662
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   663
    osTime := secs * 1000.
795
ff477bad0f2d fix setSeconds:
Stefan Vogel <sv@exept.de>
parents: 699
diff changeset
   664
ff477bad0f2d fix setSeconds:
Stefan Vogel <sv@exept.de>
parents: 699
diff changeset
   665
    "Modified: 20.12.1995 / 11:46:36 / stefan"
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   666
    "Modified: 1.7.1996 / 14:34:10 / cg"
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   667
! !
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   668
2311
88b035dd471a New Method: #secondsSince1970.
Stefan Vogel <sv@exept.de>
parents: 1701
diff changeset
   669
!AbsoluteTime class methodsFor:'documentation'!
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   670
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   671
version
2311
88b035dd471a New Method: #secondsSince1970.
Stefan Vogel <sv@exept.de>
parents: 1701
diff changeset
   672
    ^ '$Header: /cvs/stx/stx/libbasic/Attic/AbsTime.st,v 1.31 1997-01-29 18:02:03 stefan Exp $'
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   673
! !