Timestamp.st
author Claus Gittinger <cg@exept.de>
Fri, 20 Sep 1996 09:29:27 +0200
changeset 1669 4951596746f7
parent 1521 7c3ceed93df7
child 1701 80d13adb2e77
permissions -rw-r--r--
comments & code cleanup
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
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
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
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
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
    "
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   102
     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
   103
     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
   104
    "
1228
127d990e2f77 commentary
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   105
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   106
    "Created: 1.7.1996 / 14:46:09 / cg"
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   107
    "Modified: 1.7.1996 / 15:22:07 / cg"
275
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   108
!
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   109
423
claus
parents: 392
diff changeset
   110
fromDate:aDate andTime:aTime
claus
parents: 392
diff changeset
   111
    "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
   112
     object.
127d990e2f77 commentary
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   113
     See also `AbsoluteTime now' and other protocol inherited
127d990e2f77 commentary
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   114
     from my superclass."
423
claus
parents: 392
diff changeset
   115
claus
parents: 392
diff changeset
   116
    ^ self 
1228
127d990e2f77 commentary
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   117
        day:aDate day 
127d990e2f77 commentary
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   118
        month:aDate month 
127d990e2f77 commentary
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   119
        year:aDate year 
127d990e2f77 commentary
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   120
        hour:aTime hours 
127d990e2f77 commentary
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   121
        minutes:aTime minutes 
127d990e2f77 commentary
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   122
        seconds:aTime seconds 
423
claus
parents: 392
diff changeset
   123
claus
parents: 392
diff changeset
   124
    "
1228
127d990e2f77 commentary
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   125
     AbsoluteTime fromDate:(Date today) andTime:(Time now)  
127d990e2f77 commentary
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   126
     AbsoluteTime fromDate:(Date today plusDays:1) andTime:(Time now) 
127d990e2f77 commentary
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   127
     AbsoluteTime now 
423
claus
parents: 392
diff changeset
   128
    "
claus
parents: 392
diff changeset
   129
claus
parents: 392
diff changeset
   130
    "Modified: 8.9.1995 / 15:07:30 / claus"
1228
127d990e2f77 commentary
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   131
    "Modified: 19.4.1996 / 15:25:46 / cg"
423
claus
parents: 392
diff changeset
   132
!
claus
parents: 392
diff changeset
   133
1513
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   134
newDay:dayInYear year:year
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   135
    "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
   136
     Date protocol compatibility"
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   137
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   138
    ^ (Date newDay:dayInYear year:year) asAbsoluteTime
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
    "
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   141
     AbsoluteTime newDay:183 year:1996
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
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   144
    "Modified: 2.7.1996 / 09:39:30 / cg"
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
569
7134eb78cf48 readFrom:onError: can now also read from a string
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   147
readFrom:aStringOrStream onError:exceptionBlock
275
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   148
    "return a new AbsoluteTime, reading a printed representation from aStream.
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   149
     The string is interpreted as 24 hour format, as printed.
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   150
     Notice, that this is not the storeString format and 
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   151
     is different from the format expected by readFrom:."
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   152
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   153
    |str day month year hour min sec millis ex|
569
7134eb78cf48 readFrom:onError: can now also read from a string
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   154
7134eb78cf48 readFrom:onError: can now also read from a string
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   155
    str := aStringOrStream readStream.
275
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   156
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   157
    ex := [^ exceptionBlock value].
569
7134eb78cf48 readFrom:onError: can now also read from a string
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   158
    day := Integer readFrom:str onError:ex.
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   159
    (day between:1 and:31) ifFalse:[^ exceptionBlock value].
275
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   160
569
7134eb78cf48 readFrom:onError: can now also read from a string
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   161
    [str peek isDigit] whileFalse:[str next].
7134eb78cf48 readFrom:onError: can now also read from a string
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   162
    month := Integer readFrom:str onError:ex.
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   163
    (month between:1 and:12) ifFalse:[^ exceptionBlock value].
275
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   164
569
7134eb78cf48 readFrom:onError: can now also read from a string
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   165
    [str peek isDigit] whileFalse:[str next].
7134eb78cf48 readFrom:onError: can now also read from a string
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   166
    year := Integer readFrom:str onError:ex.
275
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   167
569
7134eb78cf48 readFrom:onError: can now also read from a string
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   168
    [str peek isDigit] whileFalse:[str next].
7134eb78cf48 readFrom:onError: can now also read from a string
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   169
    hour := Integer readFrom:str onError:ex.
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   170
    (hour between:0 and:24) ifFalse:[^ exceptionBlock value].
275
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   171
569
7134eb78cf48 readFrom:onError: can now also read from a string
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   172
    [str peek isDigit] whileFalse:[str next].
7134eb78cf48 readFrom:onError: can now also read from a string
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   173
    min := Integer readFrom:str onError:ex.
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   174
    (min between:0 and:59) ifFalse:[^ exceptionBlock value].
275
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   175
569
7134eb78cf48 readFrom:onError: can now also read from a string
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   176
    [str peek isDigit] whileFalse:[str next].
7134eb78cf48 readFrom:onError: can now also read from a string
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   177
    sec := Integer readFrom:str onError:ex.
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   178
    (sec between:0 and:59) ifFalse:[^ exceptionBlock value].
275
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   179
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   180
    str peek = '.' ifTrue:[
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   181
        str next.
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   182
        millis := Integer readFrom:str onError:ex.
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   183
    ] ifFalse:[
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   184
        millis := 0.
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   185
    ].
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   186
275
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   187
    "special check"
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   188
    hour == 24 ifTrue:[
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   189
        (min ~~ 0 or:[sec ~~ 0]) ifTrue:[^ exceptionBlock value].
275
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   190
    ].
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   191
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   192
    ^ self day:day month:month year:year hour:hour minutes:min seconds:sec
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   193
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   194
    "
569
7134eb78cf48 readFrom:onError: can now also read from a string
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   195
     AbsoluteTime readFrom:'20-2-1995 13:11:06'    
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   196
     AbsoluteTime readFrom:'20-2-1995 13:11:06.100'    
275
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   197
    "
569
7134eb78cf48 readFrom:onError: can now also read from a string
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   198
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   199
    "Modified: 1.7.1996 / 14:44:09 / cg"
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   200
! !
30
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
   201
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
   202
!AbsoluteTime methodsFor:'accessing'!
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
   203
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
   204
day
92
0c73b48551ac *** empty log message ***
claus
parents: 82
diff changeset
   205
    "return the day-in-month of the receiver (1..31).
275
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   206
     For compatibility, use instances of Date for this."
30
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
   207
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   208
    |d|
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   209
275
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   210
    OperatingSystem computeDatePartsOf:osTime for:[:year :month :day |
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   211
        d := day
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   212
    ].
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   213
    ^ d
54
06dbdeeed4f9 *** empty log message ***
claus
parents: 30
diff changeset
   214
92
0c73b48551ac *** empty log message ***
claus
parents: 82
diff changeset
   215
    "
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   216
     AbsoluteTime now day 
92
0c73b48551ac *** empty log message ***
claus
parents: 82
diff changeset
   217
    "
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   218
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   219
    "Modified: 1.7.1996 / 15:23:02 / cg"
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   220
!
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   221
1513
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   222
dayInWeek
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   223
    "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
   224
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   225
    |info|
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   226
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   227
    info := OperatingSystem computeTimeAndDateFrom:osTime.
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   228
    ^ info at:11
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   229
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   230
    "
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   231
     AbsoluteTime now dayInWeek 
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   232
    "
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   233
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   234
    "Modified: 2.7.1996 / 09:20:32 / cg"
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   235
    "Created: 2.7.1996 / 09:35:48 / cg"
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   236
!
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   237
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   238
dayInYear
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   239
    "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
   240
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   241
    |info|
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   242
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   243
    info := OperatingSystem computeTimeAndDateFrom:osTime.
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   244
    ^ info at:10
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
    "
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   247
     AbsoluteTime now dayInYear  
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   248
     AbsoluteTime newDay:184 year:1996  
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   249
    "
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
    "Modified: 2.7.1996 / 10:21:02 / cg"
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   252
!
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   253
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   254
hour
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   255
    "return the hour (0..23).
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   256
     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
   257
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   258
    ^ self hours
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   259
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   260
    "Created: 1.7.1996 / 15:14:50 / cg"
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   261
    "Modified: 1.7.1996 / 15:15:32 / cg"
30
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
   262
!
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
   263
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   264
hours
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   265
    "return the hours (0..23)"
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   266
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   267
    |hr|
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   268
1513
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   269
    OperatingSystem computeTimePartsOf:osTime for:[:hours :minutes :secs :millis |
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   270
        hr := hours
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   271
    ].
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   272
    ^ hr
54
06dbdeeed4f9 *** empty log message ***
claus
parents: 30
diff changeset
   273
92
0c73b48551ac *** empty log message ***
claus
parents: 82
diff changeset
   274
    "
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   275
     AbsoluteTime now hours 
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   276
    "
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   277
1513
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   278
    "Modified: 2.7.1996 / 09:20:32 / cg"
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   279
!
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
millisecond
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   282
    "return the millisecond (0..999).
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   283
     ST-80 Timestamp compatibility (I'd prefer the name #milliseconds)."
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   284
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   285
    ^ self milliseconds
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   286
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   287
    "Created: 1.7.1996 / 15:14:50 / cg"
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   288
    "Modified: 1.7.1996 / 15:15:24 / cg"
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   289
!
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   290
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   291
milliseconds
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   292
    "return the milliseconds (0..999)"
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   293
1513
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   294
    |m|
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   295
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   296
    OperatingSystem computeTimePartsOf:osTime for:[:hours :minutes :secs :millis |
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   297
        m := millis
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   298
    ].
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   299
    ^ m
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
    "
1513
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   302
     AbsoluteTime now milliseconds   
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   303
    "
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   304
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   305
    "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
   306
    "Modified: 2.7.1996 / 09:21:41 / cg"
1501
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
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   309
minute
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   310
    "return the minute (0..59).
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   311
     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
   312
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   313
    ^ self minutes
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   314
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   315
    "Created: 1.7.1996 / 15:14:29 / cg"
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   316
    "Modified: 1.7.1996 / 15:15:37 / cg"
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   317
!
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   318
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   319
minutes
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   320
    "return the minutes (0..59)"
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   321
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   322
    |m|
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   323
1513
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   324
    OperatingSystem computeTimePartsOf:osTime for:[:hours :minutes :secs :millis |
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   325
        m := minutes
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   326
    ].
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   327
    ^ m
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   328
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   329
    "
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   330
     AbsoluteTime now minutes 
92
0c73b48551ac *** empty log message ***
claus
parents: 82
diff changeset
   331
    "
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   332
1513
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   333
    "Modified: 2.7.1996 / 09:20:49 / cg"
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   334
!
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   335
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   336
month
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   337
    "return the month of the receiver (1..12).
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   338
     For compatibility, use instances of Date for this."
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   339
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   340
    |m|
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   341
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   342
    OperatingSystem computeDatePartsOf:osTime for:[ :year :month :day |
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   343
        m := month
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   344
    ].
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   345
    ^ m
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   346
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   347
    "
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   348
     AbsoluteTime now month
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   349
    "
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   350
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   351
    "Modified: 1.7.1996 / 15:23:05 / cg"
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   352
!
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   353
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   354
second
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   355
    "return the second (0..59).
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   356
     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
   357
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   358
    ^ self seconds
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   359
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   360
    "Created: 1.7.1996 / 15:14:19 / cg"
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   361
    "Modified: 1.7.1996 / 15:15:49 / cg"
699
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
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   364
seconds
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   365
    "return the seconds (0..59)"
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   366
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   367
    |s|
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   368
1513
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   369
    OperatingSystem computeTimePartsOf:osTime for:[:hours :minutes :secs :millis |
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   370
        s := secs
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   371
    ].
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   372
    ^ s
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   373
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   374
    "
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   375
     AbsoluteTime now seconds 
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   376
    "
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   377
1513
a4b4c4ce039c added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents: 1501
diff changeset
   378
    "Modified: 2.7.1996 / 09:20:54 / cg"
92
0c73b48551ac *** empty log message ***
claus
parents: 82
diff changeset
   379
!
0c73b48551ac *** empty log message ***
claus
parents: 82
diff changeset
   380
799
33cf42458eee New Method utcOffset
Stefan Vogel <sv@exept.de>
parents: 795
diff changeset
   381
utcOffset
33cf42458eee New Method utcOffset
Stefan Vogel <sv@exept.de>
parents: 795
diff changeset
   382
    "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
   383
     if daylight saving time applies to ourself, take that into account.
33cf42458eee New Method utcOffset
Stefan Vogel <sv@exept.de>
parents: 795
diff changeset
   384
     Add utcOffset bevor converting to get UTC-Time resp. UTC-Date.
33cf42458eee New Method utcOffset
Stefan Vogel <sv@exept.de>
parents: 795
diff changeset
   385
    "
33cf42458eee New Method utcOffset
Stefan Vogel <sv@exept.de>
parents: 795
diff changeset
   386
33cf42458eee New Method utcOffset
Stefan Vogel <sv@exept.de>
parents: 795
diff changeset
   387
    ^ (OperatingSystem computeTimeAndDateFrom:osTime) at:7
33cf42458eee New Method utcOffset
Stefan Vogel <sv@exept.de>
parents: 795
diff changeset
   388
33cf42458eee New Method utcOffset
Stefan Vogel <sv@exept.de>
parents: 795
diff changeset
   389
    "
33cf42458eee New Method utcOffset
Stefan Vogel <sv@exept.de>
parents: 795
diff changeset
   390
     AbsoluteTime now utcOffset 
33cf42458eee New Method utcOffset
Stefan Vogel <sv@exept.de>
parents: 795
diff changeset
   391
     (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
   392
    "
33cf42458eee New Method utcOffset
Stefan Vogel <sv@exept.de>
parents: 795
diff changeset
   393
33cf42458eee New Method utcOffset
Stefan Vogel <sv@exept.de>
parents: 795
diff changeset
   394
    "Modified: 20.12.1995 / 17:28:49 / stefan"
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   395
    "Modified: 1.7.1996 / 15:21:29 / cg"
799
33cf42458eee New Method utcOffset
Stefan Vogel <sv@exept.de>
parents: 795
diff changeset
   396
!
33cf42458eee New Method utcOffset
Stefan Vogel <sv@exept.de>
parents: 795
diff changeset
   397
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   398
year
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   399
    "return the year of the receiver i.e. 1992.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   400
     For compatibility, use instances of Date for this."
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   401
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   402
    |y|
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   403
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   404
    OperatingSystem computeDatePartsOf:osTime for:[:year :month :day |
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   405
        y := year
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   406
    ].
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   407
    ^ y
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   408
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   409
    "
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   410
     AbsoluteTime now year
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   411
    "
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   412
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   413
    "Modified: 1.7.1996 / 15:23:08 / cg"
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   414
! !
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   415
30
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
   416
!AbsoluteTime methodsFor:'arithmetic'!
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
   417
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
   418
- aTime
242
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   419
    "return the delta in seconds between 2 times."
30
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
   420
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
   421
    ^ self getSeconds - (aTime getSeconds)
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
   422
!
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
   423
242
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   424
addDays:numberOfDays
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   425
    "return a new instance of myself, numberOfDays afterwards."
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   426
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   427
    ^ self addSeconds:(numberOfDays * (60 * 60 * 24))
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   428
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   429
    "
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   430
     |t|
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   431
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   432
     t := AbsoluteTime now.
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   433
     t printNL.
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   434
     (t addDays:7) printNL
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   435
    "
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   436
!
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   437
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   438
subtractDays:numberOfDays
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   439
    "return a new instance of myself, numberOfDays before."
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   440
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   441
    ^ self subtractSeconds:(numberOfDays * (60 * 60 * 24))
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   442
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   443
    "
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   444
     |t|
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   445
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   446
     t := AbsoluteTime now.
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   447
     t printNL.
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   448
     (t subtractDays:50) printNL
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   449
    "
30
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
   450
! !
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
   451
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   452
!AbsoluteTime methodsFor:'comparing'!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   453
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   454
< aTime
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   455
    "return true if the argument, aTime is before the receiver"
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   456
1520
da08f8e49e87 fixed comparing absoluteTimes
Claus Gittinger <cg@exept.de>
parents: 1513
diff changeset
   457
    ^ self getMilliseconds < aTime getMilliseconds
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   458
1520
da08f8e49e87 fixed comparing absoluteTimes
Claus Gittinger <cg@exept.de>
parents: 1513
diff changeset
   459
    "Modified: 3.7.1996 / 13:10:17 / cg"
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   460
!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   461
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   462
= aTime
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   463
    "return true if the argument, aTime represents the same time"
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   464
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   465
    (aTime species == self species) ifFalse:[^ false].
1520
da08f8e49e87 fixed comparing absoluteTimes
Claus Gittinger <cg@exept.de>
parents: 1513
diff changeset
   466
    ^ (self getMilliseconds = aTime getMilliseconds)
da08f8e49e87 fixed comparing absoluteTimes
Claus Gittinger <cg@exept.de>
parents: 1513
diff changeset
   467
da08f8e49e87 fixed comparing absoluteTimes
Claus Gittinger <cg@exept.de>
parents: 1513
diff changeset
   468
    "Modified: 3.7.1996 / 13:10:24 / cg"
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   469
!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   470
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   471
> aTime
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   472
    "return true if the argument, aTime is after the receiver"
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   473
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   474
    ^ self getMilliseconds > aTime getMilliseconds
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   475
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   476
    "Modified: 1.7.1996 / 15:24:38 / cg"
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   477
!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   478
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   479
hash
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   480
    "return an integer useful for hashing on times"
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   481
1520
da08f8e49e87 fixed comparing absoluteTimes
Claus Gittinger <cg@exept.de>
parents: 1513
diff changeset
   482
    ^ osTime // 1000
da08f8e49e87 fixed comparing absoluteTimes
Claus Gittinger <cg@exept.de>
parents: 1513
diff changeset
   483
da08f8e49e87 fixed comparing absoluteTimes
Claus Gittinger <cg@exept.de>
parents: 1513
diff changeset
   484
    "Modified: 3.7.1996 / 13:10:52 / cg"
699
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
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   487
!AbsoluteTime methodsFor:'converting'!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   488
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   489
asAbsoluteTime
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   490
    "return an AbsoluteTime object from the receiver - thats the receiver."
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
    ^ self
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   493
!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   494
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   495
asDate
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   496
    "return a Date object from the receiver.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   497
     The returned date will only represent the day - not the timeOfDay."
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
    ^ Date fromOSTime:osTime 
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   500
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   501
    "
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   502
     AbsoluteTime now  
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   503
     AbsoluteTime now asDate
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   504
     (AbsoluteTime now addTime:3600) asDate 
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   505
     (AbsoluteTime now addTime:3600) asTime 
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   506
     AbsoluteTime fromSeconds:(AbsoluteTime now asSeconds + 3600) 
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   507
     (AbsoluteTime fromSeconds:(AbsoluteTime now asSeconds + 3600)) asDate  
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   508
    "
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
!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   511
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   512
asSeconds
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   513
    "return the number of seconds elapsed since whatever time the
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   514
     OperatingSystem bases its time upon. Since this is totally
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   515
     OS-dependent, do not interpret the value returned by this method.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   516
     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
   517
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   518
    ^ self getSeconds
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
    "
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   521
     AbsoluteTime now asSeconds
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   522
     AbsoluteTime fromSeconds:(AbsoluteTime now asSeconds + 3600) 
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   523
     Time hour:23 minutes:33 seconds:0         
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   524
     Time fromSeconds:((Time hour:23 minutes:33 seconds:0) asSeconds + 3600) 
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   525
    "
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   526
!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   527
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   528
asTime
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   529
    "return a Time object from the receiver.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   530
     The returned time will only represent the timeOfDay - not the day."
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
    ^ Time fromOSTime:osTime
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   533
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   534
    "
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   535
     AbsoluteTime now  
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   536
     AbsoluteTime now asTime
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   537
     (AbsoluteTime now addTime:3600) asTime 
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
! !
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   540
213
3b56a17534fd *** empty log message ***
claus
parents: 154
diff changeset
   541
!AbsoluteTime methodsFor:'printing & storing'!
30
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
   542
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   543
printOn:aStream
275
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   544
    "append a user readable representation of the receiver to aStream.
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   545
     The format is compatible with readFromString:, but not with readFrom:."
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   546
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   547
    |h min s mil d m y|
30
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
   548
275
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   549
    OperatingSystem computeDatePartsOf:osTime for:[
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   550
        :year :month :day | d := day. m := month. y := year.
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   551
    ].
275
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   552
    OperatingSystem computeTimePartsOf:osTime for:[
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   553
        :hours :minutes :secs :millis | h := hours. min := minutes. s := secs. mil := millis
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   554
    ].
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   555
    d printOn:aStream.
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   556
    aStream nextPut:$-.
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   557
    m printOn:aStream.
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   558
    aStream nextPut:$-.
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   559
    y printOn:aStream.
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   560
    aStream space.
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   561
    h printOn:aStream leftPaddedTo:2 with:$0. 
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   562
    aStream nextPut:$:.
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   563
    min printOn:aStream leftPaddedTo:2 with:$0.
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   564
    aStream nextPut:$:.
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   565
    s printOn:aStream leftPaddedTo:2 with:$0.
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   566
    mil ~~ 0 ifTrue:[
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   567
        aStream nextPut:$..
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   568
        mil printOn:aStream leftPaddedTo:3 with:$0.
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   569
    ].
92
0c73b48551ac *** empty log message ***
claus
parents: 82
diff changeset
   570
0c73b48551ac *** empty log message ***
claus
parents: 82
diff changeset
   571
    "
275
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   572
     AbsoluteTime now printOn:Transcript. Transcript cr. 
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   573
     (AbsoluteTime fromSeconds:0) printOn:Transcript. Transcript cr.
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   574
     Time now printOn:Transcript. Transcript cr.           
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   575
     Date today printOn:Transcript. Transcript cr.        
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   576
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   577
     Time now asAbsoluteTime printOn:Transcript. Transcript cr.           
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   578
     AbsoluteTime now printOn:Transcript. Transcript cr. 
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   579
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   580
     Date today asAbsoluteTime printOn:Transcript. Transcript cr.           
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   581
     Date today printOn:Transcript. Transcript cr.           
92
0c73b48551ac *** empty log message ***
claus
parents: 82
diff changeset
   582
    "
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   583
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   584
    "Modified: 1.7.1996 / 15:20:59 / cg"
30
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
   585
!
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
   586
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   587
storeOn:aStream
275
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   588
    "store the receiver in a format suitable for reconstruction of the
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   589
     receiver via readFrom:"
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   590
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   591
    aStream nextPut:$(; 
242
0190f298e56c added more addXXX/subtractXXX methods
claus
parents: 241
diff changeset
   592
	    nextPutAll:self class name; 
275
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   593
	    nextPutAll:' new setSeconds:'.
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   594
    self getSeconds storeOn:aStream.
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   595
    aStream nextPut:$).
54
06dbdeeed4f9 *** empty log message ***
claus
parents: 30
diff changeset
   596
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   597
    "
275
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   598
     AbsoluteTime now storeString 
30
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
   599
275
a76029ddaa98 *** empty log message ***
claus
parents: 242
diff changeset
   600
     AbsoluteTime readFrom:(AbsoluteTime now storeString) readStream
241
6f30be88e314 *** empty log message ***
claus
parents: 213
diff changeset
   601
    "
30
c5f5604e0c0a Initial revision
claus
parents:
diff changeset
   602
! !
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   603
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   604
!AbsoluteTime methodsFor:'private'!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   605
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   606
fromOSTime:anUninterpretedOSTime
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   607
    "strictly private: set the seconds from an OS time (since whatever)"
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   608
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   609
    osTime := anUninterpretedOSTime
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   610
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   611
    "Created: 1.7.1996 / 14:33:21 / cg"
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   612
!
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   613
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   614
getMilliseconds
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   615
    "strictly private: return the milliseconds (since whatever)"
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   616
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   617
    ^ osTime
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   618
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   619
    "Created: 1.7.1996 / 14:33:56 / cg"
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   620
!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   621
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   622
getSeconds
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   623
    "strictly private: return the seconds (since whatever)"
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   624
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   625
    ^ osTime // 1000
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   626
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   627
    "Modified: 1.7.1996 / 14:33:44 / cg"
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   628
!
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
setMilliseconds:millis
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   631
    "strictly private: set the milliseconds (since whatever)"
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   632
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   633
    osTime := millis.
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
    "Modified: 20.12.1995 / 11:46:36 / stefan"
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   636
    "Created: 1.7.1996 / 14:34:24 / cg"
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
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   639
setSeconds:secs
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   640
    "strictly private: set the seconds (since whatever)"
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   641
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   642
    osTime := secs * 1000.
795
ff477bad0f2d fix setSeconds:
Stefan Vogel <sv@exept.de>
parents: 699
diff changeset
   643
ff477bad0f2d fix setSeconds:
Stefan Vogel <sv@exept.de>
parents: 699
diff changeset
   644
    "Modified: 20.12.1995 / 11:46:36 / stefan"
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   645
    "Modified: 1.7.1996 / 14:34:10 / cg"
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   646
! !
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   647
1501
2589005c849d time changes
Claus Gittinger <cg@exept.de>
parents: 1306
diff changeset
   648
!AbsoluteTime  class methodsFor:'documentation'!
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
version
1669
4951596746f7 comments & code cleanup
Claus Gittinger <cg@exept.de>
parents: 1521
diff changeset
   651
    ^ '$Header: /cvs/stx/stx/libbasic/Timestamp.st,v 1.29 1996-09-20 07:27:00 cg Exp $'
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 569
diff changeset
   652
! !