AbstractTime.st
author Michael Beyl <mb@exept.de>
Mon, 18 Sep 2006 14:46:39 +0200
changeset 9926 5bfe280953b9
parent 9449 6ba774be6aa1
child 10485 959ce825c3b7
permissions -rw-r--r--
*** empty log message ***
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
     1
"
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
     2
 COPYRIGHT (c) 1995 by Claus Gittinger
7010
13fcdfdc95b1 add methods for squeak compatibility
penk
parents: 7007
diff changeset
     3
              All Rights Reserved
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
     4
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
    11
"
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
    12
5548
eead51e4752e added #weekInYear query
Claus Gittinger <cg@exept.de>
parents: 5191
diff changeset
    13
"{ Package: 'stx:libbasic' }"
eead51e4752e added #weekInYear query
Claus Gittinger <cg@exept.de>
parents: 5191
diff changeset
    14
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
    15
Magnitude subclass:#AbstractTime
7258
9ccdbee7d1ad method category rename
Claus Gittinger <cg@exept.de>
parents: 7010
diff changeset
    16
	instanceVariableNames:''
9ccdbee7d1ad method category rename
Claus Gittinger <cg@exept.de>
parents: 7010
diff changeset
    17
	classVariableNames:''
9ccdbee7d1ad method category rename
Claus Gittinger <cg@exept.de>
parents: 7010
diff changeset
    18
	poolDictionaries:''
7672
46f206594db3 Category change
Stefan Vogel <sv@exept.de>
parents: 7327
diff changeset
    19
	category:'Magnitude-Time'
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
    20
!
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
    21
2310
2cb1366e0eb3 Correct name: #secondDay --> #secondInDay.
Stefan Vogel <sv@exept.de>
parents: 1500
diff changeset
    22
!AbstractTime class methodsFor:'documentation'!
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
    23
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
    24
copyright
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
    25
"
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
    26
 COPYRIGHT (c) 1995 by Claus Gittinger
7010
13fcdfdc95b1 add methods for squeak compatibility
penk
parents: 7007
diff changeset
    27
              All Rights Reserved
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
    28
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
    29
 This software is furnished under a license and may be used
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
    30
 only in accordance with the terms of that license and with the
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
    31
 inclusion of the above copyright notice.   This software may not
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
    32
 be provided or otherwise made available to, or used by, any
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
    33
 other person.  No title to or ownership of the software is
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
    34
 hereby transferred.
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
    35
"
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
    36
!
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
    37
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
    38
documentation
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
    39
"
1500
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
    40
    This is an abstract class providing common protocol for Time (time in day)
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
    41
    and Timestamp (time plus day).
1500
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
    42
    There are no instances of this class in the system.
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
    43
    It is meant as a home for methods common to time handling classes.
1282
3f5eda57c516 commentary
Claus Gittinger <cg@exept.de>
parents: 1227
diff changeset
    44
1295
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 1282
diff changeset
    45
    [author:]
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 1282
diff changeset
    46
        Claus Gittinger
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 1282
diff changeset
    47
1282
3f5eda57c516 commentary
Claus Gittinger <cg@exept.de>
parents: 1227
diff changeset
    48
    [See also:]
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
    49
        Time Date Timestamp
1282
3f5eda57c516 commentary
Claus Gittinger <cg@exept.de>
parents: 1227
diff changeset
    50
        Delay ProcessorScheduler
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
    51
"
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    52
!
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    53
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    54
iso8601Format
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    55
"
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    56
  Abstract
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    57
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    58
    This document defines a profile of ISO 8601, the International Standard for the representation of dates and times. ISO
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    59
    8601 describes a large number of date/time formats. To reduce the scope for error and the complexity of software, it is
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    60
    useful to restrict the supported formats to a small number. This profile defines a few date/time formats, likely to satisfy
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    61
    most requirements. 
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    62
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    63
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    64
  Formats
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    65
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    66
    Different standards may need different levels of granularity in the date and time, so this profile defines six levels.
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    67
    Standards that reference this profile should specify one or more of these granularities. If a given standard allows more
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    68
    than one granularity, it should specify the meaning of the dates and times with reduced precision, for example, the result
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    69
    of comparing two dates with different precisions.
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    70
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    71
    The formats are as follows. Exactly the components shown here must be present, with exactly this punctuation. Note
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    72
    that the 'T' appears literally in the string, to indicate the beginning of the time element, as specified in ISO 8601. 
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    73
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    74
       Year:
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    75
          YYYY (eg 1997)
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    76
       Year and month:
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    77
          YYYY-MM (eg 1997-07)
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    78
       Complete date:
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    79
          YYYY-MM-DD (eg 1997-07-16)
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    80
       Complete date plus hours and minutes:
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    81
          YYYY-MM-DDThh:mmTZD (eg 1997-07-16T19:20+01:00)
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    82
       Complete date plus hours, minutes and seconds:
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    83
          YYYY-MM-DDThh:mm:ssTZD (eg 1997-07-16T19:20:30+01:00)
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    84
       Complete date plus hours, minutes, seconds and a decimal fraction of a
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    85
    second
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    86
          YYYY-MM-DDThh:mm:ss.sTZD (eg 1997-07-16T19:20:30.45+01:00)
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    87
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    88
    where:
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    89
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    90
         YYYY = four-digit year
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    91
         MM   = two-digit month (01=January, etc.)
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    92
         DD   = two-digit day of month (01 through 31)
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    93
         hh   = two digits of hour (00 through 23) (am/pm NOT allowed)
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    94
         mm   = two digits of minute (00 through 59)
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    95
         ss   = two digits of second (00 through 59)
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    96
         s    = one or more digits representing a decimal fraction of a second
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    97
         TZD  = time zone designator (Z or +hh:mm or -hh:mm)
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    98
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    99
    This profile does not specify how many digits may be used to represent the decimal fraction of a second. An adopting
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   100
    standard that permits fractions of a second must specify both the minimum number of digits (a number greater than or
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   101
    equal to one) and the maximum number of digits (the maximum may be stated to be 'unlimited').
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   102
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   103
    This profile defines two ways of handling time zone offsets:
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   104
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   105
       1.Times are expressed in UTC (Coordinated Universal Time), with a special UTC designator ('Z'). 
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   106
       2.Times are expressed in local time, together with a time zone offset in hours and minutes. A time zone offset of
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   107
         '+hh:mm' indicates that the date/time uses a local time zone which is 'hh' hours and 'mm' minutes ahead of
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   108
         UTC. A time zone offset of '-hh:mm' indicates that the date/time uses a local time zone which is 'hh' hours and
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   109
         'mm' minutes behind UTC. 
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   110
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   111
    A standard referencing this profile should permit one or both of these ways of handling time zone offsets.
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   112
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   113
  The ISO8601 printString are generated with:
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   114
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   115
       Year:
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   116
          YYYY (eg 1997)
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   117
                Date today printStringFormat:'%(year)'
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   118
                Timestamp now printStringFormat:'%(year)'  
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   119
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   120
       Year and month:
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   121
          YYYY-MM (eg 1997-07)
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   122
                Date today printStringFormat:'%(year)-%(month)'  
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   123
                Timestamp now printStringFormat:'%(year)-%(month)'  
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   124
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   125
       Complete date:
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   126
          YYYY-MM-DD (eg 1997-07-16)
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   127
                Date today printStringFormat:'%(year)-%(month)-%(day)'    
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   128
                Timestamp now printStringFormat:'%(year)-%(month)-%(day)'  
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   129
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   130
       Complete date plus hours and minutes:
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   131
          YYYY-MM-DDThh:mmTZD (eg 1997-07-16T19:20+01:00)
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   132
                Timestamp now printStringFormat:'%(year)-%(month)-%(day)T%h:%m%(TZD)'  
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   133
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   134
       Complete date plus hours, minutes and seconds:
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   135
          YYYY-MM-DDThh:mm:ssTZD (eg 1997-07-16T19:20:30+01:00)
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   136
                Timestamp now printStringFormat:'%(year)-%(month)-%(day)T%h:%m:%s%(TZD)'  
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   137
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   138
       Complete date plus hours, minutes, seconds and a decimal fraction of a second
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   139
          YYYY-MM-DDThh:mm:ss.sTZD (eg 1997-07-16T19:20:30.45+01:00)
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   140
                Timestamp now printStringFormat:'%(year)-%(month)-%(day)T%h:%m:%s.%(milli2)%(TZD)'  
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   141
"
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
   142
! !
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
   143
2310
2cb1366e0eb3 Correct name: #secondDay --> #secondInDay.
Stefan Vogel <sv@exept.de>
parents: 1500
diff changeset
   144
!AbstractTime class methodsFor:'instance creation'!
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
   145
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   146
dateAndTimeNow
1227
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   147
    "return an array filled with the current date and time.
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   148
     See also: Date today / Time now / Timestamp now."
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
   149
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   150
    ^ Array with:(Date today) with:(Time now)
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
   151
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
   152
    "
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   153
     Time dateAndTimeNow
7007
9af8cc2f82a4 totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents: 6888
diff changeset
   154
     Date dateAndTimeNow
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
   155
    "
1227
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   156
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   157
    "Modified: 19.4.1996 / 15:23:37 / cg"
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   158
!
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
   159
9432
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
   160
epoch
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
   161
    "answer the time when we start counting"
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
   162
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
   163
    ^ self new setSeconds:0
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
   164
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
   165
    "
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
   166
        Timestamp epoch
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
   167
        Time epoch
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
   168
    "
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
   169
!
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
   170
1227
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   171
now
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   172
    "return an instance of myself representing this moment."
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   173
1500
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
   174
    ^ self basicNew fromOSTime:(OperatingSystem getOSTime)
1227
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   175
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   176
    "
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   177
     Timestamp now   
1227
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   178
     Time now   
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   179
    "
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   180
1500
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
   181
    "Modified: 1.7.1996 / 15:20:10 / cg"
1227
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   182
! !
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   183
7294
c4e6d095a150 category changes
Claus Gittinger <cg@exept.de>
parents: 7261
diff changeset
   184
!AbstractTime class methodsFor:'Compatibility-Squeak'!
7007
9af8cc2f82a4 totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents: 6888
diff changeset
   185
9432
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
   186
dateAndTimeFromSeconds:secondCount
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
   187
    "set date and time from seconds since 1901-01-01 00:00 UTC"
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
   188
9429
173bcd493d7c Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents: 8586
diff changeset
   189
    |timestamp|
173bcd493d7c Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents: 8586
diff changeset
   190
173bcd493d7c Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents: 8586
diff changeset
   191
"   
173bcd493d7c Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents: 8586
diff changeset
   192
    secondsBetween1901and1970 := 
9432
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
   193
        (Timestamp epoch asDate subtractDate:(Date day:1 month:1 year:1901))
9429
173bcd493d7c Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents: 8586
diff changeset
   194
        *  (24 * 60 * 60)
173bcd493d7c Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents: 8586
diff changeset
   195
"
173bcd493d7c Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents: 8586
diff changeset
   196
9432
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
   197
    "stc cannot make large integers"
9449
6ba774be6aa1 stc can compile large integers!
Stefan Vogel <sv@exept.de>
parents: 9432
diff changeset
   198
    timestamp := Timestamp fromSeconds:secondCount - 2177452800.
7007
9af8cc2f82a4 totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents: 6888
diff changeset
   199
    ^ Array
9429
173bcd493d7c Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents: 8586
diff changeset
   200
        with: (timestamp asDate)
173bcd493d7c Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents: 8586
diff changeset
   201
        with: (timestamp asTime)
1227
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   202
7007
9af8cc2f82a4 totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents: 6888
diff changeset
   203
    "
9429
173bcd493d7c Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents: 8586
diff changeset
   204
     Timestamp dateAndTimeFromSeconds: (Time primSecondsClock) 
7007
9af8cc2f82a4 totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents: 6888
diff changeset
   205
     Time dateAndTimeFromSeconds: (Time totalSeconds) 
9af8cc2f82a4 totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents: 6888
diff changeset
   206
     Date dateAndTimeFromSeconds: (Time totalSeconds)
9af8cc2f82a4 totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents: 6888
diff changeset
   207
    "
9af8cc2f82a4 totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents: 6888
diff changeset
   208
!
9af8cc2f82a4 totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents: 6888
diff changeset
   209
9926
5bfe280953b9 *** empty log message ***
Michael Beyl <mb@exept.de>
parents: 9449
diff changeset
   210
millisecondsSince: lastTime
5bfe280953b9 *** empty log message ***
Michael Beyl <mb@exept.de>
parents: 9449
diff changeset
   211
        "Answer the elapsed time since last recorded in milliseconds.
5bfe280953b9 *** empty log message ***
Michael Beyl <mb@exept.de>
parents: 9449
diff changeset
   212
        Compensate for rollover."
5bfe280953b9 *** empty log message ***
Michael Beyl <mb@exept.de>
parents: 9449
diff changeset
   213
5bfe280953b9 *** empty log message ***
Michael Beyl <mb@exept.de>
parents: 9449
diff changeset
   214
        ^self milliseconds: self millisecondClockValue since: lastTime
5bfe280953b9 *** empty log message ***
Michael Beyl <mb@exept.de>
parents: 9449
diff changeset
   215
!
5bfe280953b9 *** empty log message ***
Michael Beyl <mb@exept.de>
parents: 9449
diff changeset
   216
7007
9af8cc2f82a4 totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents: 6888
diff changeset
   217
primSecondsClock
9429
173bcd493d7c Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents: 8586
diff changeset
   218
    "returns the number of seconds since 1.1.1901 UTC"
173bcd493d7c Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents: 8586
diff changeset
   219
173bcd493d7c Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents: 8586
diff changeset
   220
    ^ Timestamp now utcSecondsSince1901
1227
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   221
9429
173bcd493d7c Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents: 8586
diff changeset
   222
    "                                                 
173bcd493d7c Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents: 8586
diff changeset
   223
     Timestamp primSecondsClock 
173bcd493d7c Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents: 8586
diff changeset
   224
    "
1227
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   225
! !
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   226
7294
c4e6d095a150 category changes
Claus Gittinger <cg@exept.de>
parents: 7261
diff changeset
   227
!AbstractTime class methodsFor:'Compatibility-VW'!
7007
9af8cc2f82a4 totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents: 6888
diff changeset
   228
9af8cc2f82a4 totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents: 6888
diff changeset
   229
totalSeconds
9429
173bcd493d7c Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents: 8586
diff changeset
   230
    "returns the number of seconds since 1.1.1901 UTC"
7007
9af8cc2f82a4 totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents: 6888
diff changeset
   231
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   232
    ^ Timestamp now utcSecondsSince1901
7007
9af8cc2f82a4 totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents: 6888
diff changeset
   233
! !
9af8cc2f82a4 totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents: 6888
diff changeset
   234
7258
9ccdbee7d1ad method category rename
Claus Gittinger <cg@exept.de>
parents: 7010
diff changeset
   235
!AbstractTime class methodsFor:'private-instance creation'!
1227
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   236
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   237
fromOSTime:osTime
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   238
    "return a time, representing the time given by the operatingSystem time.
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   239
     Not meant for public use."
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   240
1500
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
   241
    ^ self basicNew fromOSTime:osTime.
418
claus
parents: 384
diff changeset
   242
1500
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
   243
    "Modified: 1.7.1996 / 15:09:54 / cg"
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
   244
!
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
   245
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   246
fromSeconds:seconds
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   247
    "return an instance that is constructed from seconds.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   248
     This method is only allowed for second values as returned by
1227
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   249
     getSeconds, possibly adding/subtracting to that. 
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   250
     Never depend on any specific interpretation of the seconds,
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   251
     since it depends on how the OperatingSystem counts time
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   252
     (some start at 1900, others with 1970 ...)"
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
   253
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   254
   ^ self basicNew setSeconds:seconds
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
   255
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
   256
    "
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   257
     Time fromSeconds:0             should return midnight
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   258
     Timestamp fromSeconds:0     on UNIX: returns 1st. Jan 1970
1227
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   259
                                    on others: dont know
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   260
     (Timestamp day:1 month:1 year:1970 hour:1 minutes:0 seconds:0)
1500
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
   261
        getSeconds                  on UNIX: returns 0
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
   262
                                    on others: dont know
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   263
    "
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   264
1500
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
   265
    "Modified: 1.7.1996 / 13:39:30 / cg"
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
   266
! !
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
   267
2310
2cb1366e0eb3 Correct name: #secondDay --> #secondInDay.
Stefan Vogel <sv@exept.de>
parents: 1500
diff changeset
   268
!AbstractTime class methodsFor:'queries'!
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   269
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   270
millisecondClockValue
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   271
    "return the millisecond clock - since this one overruns
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   272
     regularly, use the value only for short timing deltas.
5730
b377ec6357e7 comment
Claus Gittinger <cg@exept.de>
parents: 5573
diff changeset
   273
     Also remember that it wraps when comparing these values."
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   274
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   275
    ^ OperatingSystem getMillisecondTime.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   276
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   277
    "
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   278
     Time millisecondClockValue 
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   279
    "
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   280
!
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   281
8450
312e775936dc squeak stuff
Claus Gittinger <cg@exept.de>
parents: 8256
diff changeset
   282
milliseconds:msTime1 since:msTime2
312e775936dc squeak stuff
Claus Gittinger <cg@exept.de>
parents: 8256
diff changeset
   283
    "return the number of milliseconds between two
312e775936dc squeak stuff
Claus Gittinger <cg@exept.de>
parents: 8256
diff changeset
   284
     millisecond time values, compensating for roll-over.
312e775936dc squeak stuff
Claus Gittinger <cg@exept.de>
parents: 8256
diff changeset
   285
     The same as millisecondsBetween:and: for Squeak compatibility."
312e775936dc squeak stuff
Claus Gittinger <cg@exept.de>
parents: 8256
diff changeset
   286
312e775936dc squeak stuff
Claus Gittinger <cg@exept.de>
parents: 8256
diff changeset
   287
    ^ OperatingSystem millisecondTimeDeltaBetween:msTime1 and:msTime2
312e775936dc squeak stuff
Claus Gittinger <cg@exept.de>
parents: 8256
diff changeset
   288
!
312e775936dc squeak stuff
Claus Gittinger <cg@exept.de>
parents: 8256
diff changeset
   289
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   290
secondClock
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   291
    "return seconds of now - for GNU-ST compatibility"
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   292
1500
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
   293
    ^ OperatingSystem getOSTime // 1000
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   294
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   295
    "
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   296
     AbstractTime secondClock    
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   297
    "
1500
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
   298
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
   299
    "Modified: 1.7.1996 / 15:20:14 / cg"
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   300
! !
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   301
2310
2cb1366e0eb3 Correct name: #secondDay --> #secondInDay.
Stefan Vogel <sv@exept.de>
parents: 1500
diff changeset
   302
!AbstractTime class methodsFor:'timing evaluations'!
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   303
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   304
millisecondsToRun:aBlock
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   305
    "evaluate the argument, aBlock; return the number of milliseconds it took"
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   306
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   307
    |startTime endTime|
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   308
1476
02f69251f5bc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   309
    startTime := OperatingSystem getMillisecondTime.
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   310
    aBlock value.
1476
02f69251f5bc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   311
    endTime := OperatingSystem getMillisecondTime.
8586
a38e882affa5 take care of time-wrap in #millisecondsToRun:
Stefan Vogel <sv@exept.de>
parents: 8450
diff changeset
   312
    ^ self milliseconds:endTime since:startTime
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   313
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   314
    "
8586
a38e882affa5 take care of time-wrap in #millisecondsToRun:
Stefan Vogel <sv@exept.de>
parents: 8450
diff changeset
   315
     Time millisecondsToRun:[1000 factorial]  
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   316
    "
1476
02f69251f5bc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   317
02f69251f5bc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   318
    "Modified: 17.6.1996 / 16:57:37 / cg"
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   319
!
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   320
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   321
secondsToRun:aBlock
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   322
    "evaluate the argument, aBlock; return the number of seconds it took"
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   323
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   324
    |startTime endTime|
360
claus
parents: 275
diff changeset
   325
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   326
    startTime := self secondClock.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   327
    aBlock value.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   328
    endTime := self secondClock.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   329
    ^ endTime - startTime
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   330
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   331
    "
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   332
     Time secondsToRun:[1000 factorial]  
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   333
    "
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   334
! !
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   335
7261
f35fc9cee675 method category rename
Claus Gittinger <cg@exept.de>
parents: 7258
diff changeset
   336
!AbstractTime methodsFor:'Compatibility-ANSI'!
6419
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   337
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   338
hour12
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   339
    "return the hour (1..12)."
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   340
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   341
    ^ self hours - 1 \\ 12 + 1.
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   342
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   343
    "
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   344
     Time now hour12   
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   345
     Time now hour24   
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   346
     (Time hours:0 minutes:0 seconds:0) hour24   
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   347
     (Time hours:0 minutes:0 seconds:0) hour12   
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   348
     (Time hours:1 minutes:0 seconds:0) hour24   
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   349
     (Time hours:1 minutes:0 seconds:0) hour12   
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   350
     (Time hours:12 minutes:0 seconds:0) hour24 
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   351
     (Time hours:12 minutes:0 seconds:0) hour12   
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   352
     (Time hours:13 minutes:0 seconds:0) hour24 
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   353
     (Time hours:13 minutes:0 seconds:0) hour12   
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   354
     (Time hours:23 minutes:0 seconds:0) hour24 
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   355
     (Time hours:23 minutes:0 seconds:0) hour12   
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   356
     (Time hours:24 minutes:0 seconds:0) hour24 
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   357
     (Time hours:24 minutes:0 seconds:0) hour12   
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   358
    "
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   359
!
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   360
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   361
hour24
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   362
    "return the hour (0..23)."
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   363
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   364
    ^ self hours
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   365
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   366
    "
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   367
     Time now hour12   
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   368
     Time now hour24   
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   369
     (Time hours:0 minutes:0 seconds:0) hour24 
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   370
     (Time hours:0 minutes:0 seconds:0) hour12 
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   371
     (Time hours:1 minutes:0 seconds:0) hour24 
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   372
     (Time hours:1 minutes:0 seconds:0) hour12 
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   373
     (Time hours:12 minutes:0 seconds:0) hour24 
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   374
     (Time hours:12 minutes:0 seconds:0) hour12 
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   375
     (Time hours:13 minutes:0 seconds:0) hour24 
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   376
     (Time hours:13 minutes:0 seconds:0) hour12 
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   377
     (Time hours:23 minutes:0 seconds:0) hour24 
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   378
     (Time hours:23 minutes:0 seconds:0) hour12 
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   379
     (Time hours:24 minutes:0 seconds:0) hour24 
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   380
     (Time hours:24 minutes:0 seconds:0) hour12 
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   381
    "
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   382
!
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   383
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   384
meridianAbbreviation
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   385
    "am/pm"
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   386
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   387
    self hours // 12 == 0 ifTrue:[
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   388
        ^ 'am'.
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   389
    ] ifFalse:[
8200
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   390
        (self hours == 12 and:[self minutes == 0 and:[self seconds == 0]]) ifTrue:[
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   391
            ^ 'noon'
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   392
        ].
6419
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   393
        ^ 'pm'.
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   394
    ].
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   395
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   396
    "
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   397
     Time now meridianAbbreviation   
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   398
     (Time hours:0 minutes:0 seconds:0) meridianAbbreviation  
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   399
     (Time hours:11 minutes:59 seconds:59) meridianAbbreviation  
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   400
     (Time hours:12 minutes:0 seconds:0) meridianAbbreviation    
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   401
     (Time hours:12 minutes:0 seconds:1) meridianAbbreviation  
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   402
    "
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   403
! !
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   404
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   405
!AbstractTime methodsFor:'abstract'!
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   406
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   407
hours
8200
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   408
    "return the hour of time (0..23)"
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   409
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   410
    ^ self subclassResponsibility
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   411
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   412
    "
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   413
     Timestamp now hours 
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   414
     Time now hours 
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   415
    "
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   416
!
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   417
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   418
milliseconds
8200
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   419
    "return the milliseconds since the start of the second (0..999)"
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   420
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   421
    ^ self subclassResponsibility
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   422
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   423
    "
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   424
     Timestamp now milliseconds 
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   425
     Time now milliseconds 
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   426
    "
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   427
!
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   428
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   429
minutes
8200
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   430
    "return the minutes since the start of the hour (0..59)"
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   431
7672
46f206594db3 Category change
Stefan Vogel <sv@exept.de>
parents: 7327
diff changeset
   432
    ^ self subclassResponsibility.
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   433
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   434
    "
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   435
     Timestamp now minutes 
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   436
     Time now minutes 
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   437
    "
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   438
!
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   439
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   440
seconds
8200
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   441
    "return the seconds since the start of the minute (0..59)"
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   442
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   443
    ^ self subclassResponsibility
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   444
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   445
    "
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   446
     Timestamp now seconds. 
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   447
     Time now seconds 
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   448
    "
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   449
! !
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   450
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   451
!AbstractTime methodsFor:'accessing'!
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   452
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   453
hourInDay
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   454
    "return the hours (0..23)"
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   455
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   456
    ^ self hours
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   457
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   458
    "
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   459
     Timestamp now hourInDay 
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   460
     Time now hourInDay 
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   461
    "
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   462
!
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   463
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   464
minuteInDay
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   465
    "return the minutes (0..59)"
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   466
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   467
    ^ self minutes.
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   468
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   469
    "
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   470
     Timestamp now minuteInDay 
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   471
     Time now minuteInDay 
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   472
    "
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   473
!
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   474
2310
2cb1366e0eb3 Correct name: #secondDay --> #secondInDay.
Stefan Vogel <sv@exept.de>
parents: 1500
diff changeset
   475
secondInDay
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   476
    "return the seconds (0..59)"
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   477
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   478
    ^ self seconds
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   479
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   480
    "
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   481
     Timestamp now secondInDay 
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   482
     Time now seconds 
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   483
    "
2310
2cb1366e0eb3 Correct name: #secondDay --> #secondInDay.
Stefan Vogel <sv@exept.de>
parents: 1500
diff changeset
   484
2cb1366e0eb3 Correct name: #secondDay --> #secondInDay.
Stefan Vogel <sv@exept.de>
parents: 1500
diff changeset
   485
    "Created: 22.10.1996 / 09:27:47 / stefan"
5548
eead51e4752e added #weekInYear query
Claus Gittinger <cg@exept.de>
parents: 5191
diff changeset
   486
!
eead51e4752e added #weekInYear query
Claus Gittinger <cg@exept.de>
parents: 5191
diff changeset
   487
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   488
timeZoneDeltaInMinutes
9432
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
   489
    "answer the number of minutes between local time and utc time.
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
   490
     Delta is positive if local time is ahead of utc, negative if behind utc."
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
   491
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   492
    ^ 0
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   493
!
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   494
5968
4832ed93f0b4 preps for timeZone
Claus Gittinger <cg@exept.de>
parents: 5964
diff changeset
   495
timeZoneName
4832ed93f0b4 preps for timeZone
Claus Gittinger <cg@exept.de>
parents: 5964
diff changeset
   496
    ^ 'utc'
4832ed93f0b4 preps for timeZone
Claus Gittinger <cg@exept.de>
parents: 5964
diff changeset
   497
!
4832ed93f0b4 preps for timeZone
Claus Gittinger <cg@exept.de>
parents: 5964
diff changeset
   498
5548
eead51e4752e added #weekInYear query
Claus Gittinger <cg@exept.de>
parents: 5191
diff changeset
   499
weekInYear
eead51e4752e added #weekInYear query
Claus Gittinger <cg@exept.de>
parents: 5191
diff changeset
   500
    "return the week number of the receiver - 1 for Jan, 1st."
eead51e4752e added #weekInYear query
Claus Gittinger <cg@exept.de>
parents: 5191
diff changeset
   501
eead51e4752e added #weekInYear query
Claus Gittinger <cg@exept.de>
parents: 5191
diff changeset
   502
    ^ Date weekInYearOf:self
eead51e4752e added #weekInYear query
Claus Gittinger <cg@exept.de>
parents: 5191
diff changeset
   503
eead51e4752e added #weekInYear query
Claus Gittinger <cg@exept.de>
parents: 5191
diff changeset
   504
    "
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   505
     (Timestamp newDay:1 year:2000) weekInYear    
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   506
     (Timestamp newDay:2 year:2000) weekInYear    
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   507
     (Timestamp newDay:3 year:2000) weekInYear    
5548
eead51e4752e added #weekInYear query
Claus Gittinger <cg@exept.de>
parents: 5191
diff changeset
   508
    "
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   509
! !
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   510
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   511
!AbstractTime methodsFor:'arithmetic'!
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   512
8200
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   513
+ aNumber
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   514
    "Add aNumber numberOfSeconds"
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   515
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   516
    ^ self species basicNew 
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   517
        setMilliseconds:(self getMilliseconds + (aNumber * 1000) asInteger)
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   518
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   519
    "
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   520
     Timestamp now to:(Timestamp now + 30) by:2 do:[:time|
8200
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   521
        Transcript showCR:time.
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   522
     ].
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   523
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   524
     (Timestamp now + 20)  -  Timestamp now 
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   525
     (Timestamp now + 0.5)  -  Timestamp now 
8200
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   526
    "
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   527
!
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   528
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   529
- aTimeOrNumberOfSeconds
8244
06543e00260e comment
Claus Gittinger <cg@exept.de>
parents: 8200
diff changeset
   530
    "return the delta in seconds between 2 times or subtract a number of seconds."
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   531
8200
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   532
    aTimeOrNumberOfSeconds isNumber ifTrue:[
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   533
        ^ self species basicNew 
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   534
            setMilliseconds:(self getMilliseconds - (aTimeOrNumberOfSeconds * 1000) asInteger)
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   535
    ].
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   536
    ^ self getSeconds - aTimeOrNumberOfSeconds getSeconds
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   537
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   538
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   539
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   540
    "
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   541
     Timestamp now - 3600.
8200
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   542
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   543
     |t1 t2|
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   544
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   545
     t1 := Timestamp now.
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   546
     (Delay forSeconds:5) wait.
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   547
     t2 := Timestamp now.
3476
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   548
     Transcript showCR:('seconds passed: ' , (t2 - t1) printString).
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   549
    "
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   550
!
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   551
6048
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   552
addDays:numberOfDays
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   553
    "return a new instance of myself, numberOfDays afterwards."
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   554
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   555
    ^ self addSeconds:(numberOfDays * (60 * 60 * 24))
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   556
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   557
    "
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   558
     |t|
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   559
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   560
     t := Timestamp now.
6048
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   561
     Transcript showCR:t.
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   562
     Transcript showCR:(t addDays:7)
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   563
    "
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   564
!
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   565
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   566
addHours:numberOfHours
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   567
    "return a new instance of myself, numberOfHours afterwards."
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   568
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   569
    ^ self addSeconds:(numberOfHours * (60 * 60))
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   570
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   571
    "
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   572
     |t|
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   573
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   574
     t := Timestamp now.
3476
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   575
     Transcript showCR:t.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   576
     Transcript showCR:(t addHours:12).
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   577
    "
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   578
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   579
    "
3476
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   580
     |t|
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   581
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   582
     t := Time now.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   583
     Transcript showCR:t.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   584
     Transcript showCR:(t addHours:12).
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   585
    "
6043
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   586
!
3476
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   587
6043
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   588
addMilliseconds:numberOfMilliSeconds
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   589
    "return a new instance of myself, numberOfMilliSeconds afterwards."
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   590
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   591
    ^ self species basicNew 
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   592
        setMilliseconds:(self getMilliseconds + numberOfMilliSeconds)
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   593
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   594
    "
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   595
     |t|
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   596
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   597
     t := Timestamp now.
6043
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   598
     Transcript showCR:t.
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   599
     Transcript showCR:(t addMilliseconds:100).
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   600
    "
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   601
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   602
    "
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   603
     |t|
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   604
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   605
     t := Time now.
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   606
     Transcript showCR:t.
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   607
     Transcript showCR:(t addMilliseconds:1000).
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   608
    "
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   609
!
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   610
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   611
addMinutes:numberOfMinutes
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   612
    "return a new instance of myself, numberOfMinutes afterwards."
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   613
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   614
    ^ self addSeconds:(numberOfMinutes * 60)
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   615
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   616
    "
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   617
     |t|
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   618
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   619
     t := Timestamp now.
3476
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   620
     Transcript showCR:t.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   621
     Transcript showCR:(t addMinutes:60).
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   622
    "
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   623
3476
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   624
    "
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   625
     |t|
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   626
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   627
     t := Time now.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   628
     Transcript showCR:t.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   629
     Transcript showCR:(t addMinutes:60).
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   630
    "
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   631
!
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   632
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   633
addSeconds:numberOfSeconds
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   634
    "return a new instance of myself, numberOfSeconds afterwards."
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   635
3476
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   636
    ^ self species basicNew 
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   637
        setMilliseconds:(self getMilliseconds + (numberOfSeconds * 1000))
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   638
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   639
    "
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   640
     |t|
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   641
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   642
     t := Timestamp now.
3476
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   643
     Transcript showCR:t.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   644
     Transcript showCR:(t addSeconds:60).
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   645
    "
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   646
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   647
    "
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   648
     |t|
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   649
3476
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   650
     t := Time now.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   651
     Transcript showCR:t.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   652
     Transcript showCR:(t addSeconds:60).
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   653
    "
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   654
!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   655
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   656
addTime:timeAmount
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   657
    "return a new instance of myself, timeAmount seconds afterwards.
3476
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   658
     Provided for ST-80 compatibility.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   659
     WARNING:
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   660
        AddTime is a bad name - it does not add a time, but expects
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   661
        a numberOfSeconds as argument. 
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   662
        Use any of addSeconds/addHours etc. to make things clear"
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   663
6888
d75cbe2e8ef7 addTime / subtractTime handle non-Number argument
Claus Gittinger <cg@exept.de>
parents: 6795
diff changeset
   664
    timeAmount isNumber ifFalse:[
d75cbe2e8ef7 addTime / subtractTime handle non-Number argument
Claus Gittinger <cg@exept.de>
parents: 6795
diff changeset
   665
        ^ self addSeconds:(timeAmount asSeconds).
d75cbe2e8ef7 addTime / subtractTime handle non-Number argument
Claus Gittinger <cg@exept.de>
parents: 6795
diff changeset
   666
    ].
3476
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   667
    ^ self addSeconds:timeAmount
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   668
!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   669
6048
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   670
subtractDays:numberOfDays
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   671
    "return a new instance of myself, numberOfDays before."
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   672
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   673
    ^ self subtractSeconds:(numberOfDays * (60 * 60 * 24))
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   674
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   675
    "
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   676
     |t|
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   677
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   678
     t := Timestamp now.
6048
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   679
     Transcript showCR:t.
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   680
     Transcript showCR:(t subtractDays:50)
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   681
    "
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   682
!
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   683
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   684
subtractHours:numberOfHours
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   685
    "return a new instance of myself, numberOfHours before."
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   686
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   687
    ^ self subtractSeconds:(numberOfHours * (60 * 60))
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   688
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   689
    "
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   690
     |t|
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   691
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   692
     t := Timestamp now.
3476
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   693
     Transcript showCR:t.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   694
     Transcript showCR:(t subtractHours:12).
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   695
    "
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   696
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   697
    "
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   698
     |t|
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   699
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   700
     t := Time now.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   701
     Transcript showCR:t.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   702
     Transcript showCR:(t subtractHours:12).
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   703
    "
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   704
!
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   705
6043
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   706
subtractMilliseconds:numberOfMilliSeconds
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   707
    "return a new instance of myself, numberOfMilliSeconds before."
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   708
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   709
    ^ self species basicNew 
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   710
        setMilliseconds:(self getMilliseconds - numberOfMilliSeconds)
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   711
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   712
    "
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   713
     |t|
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   714
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   715
     t := Timestamp now.
6043
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   716
     Transcript showCR:t.
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   717
     Transcript showCR:(t subtractMilliseconds:100).
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   718
    "
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   719
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   720
    "
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   721
     |t|
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   722
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   723
     t := Time now.
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   724
     Transcript showCR:t.
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   725
     Transcript showCR:(t subtractMilliseconds:1000).
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   726
    "
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   727
!
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   728
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   729
subtractMinutes:numberOfMinutes
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   730
    "return a new instance of myself, numberOfMinutes before."
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   731
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   732
    ^ self subtractSeconds:(numberOfMinutes * 60)
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   733
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   734
    "
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   735
     |t|
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   736
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   737
     t := Timestamp now.
3476
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   738
     Transcript showCR:t.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   739
     Transcript showCR:(t subtractMinutes:60).
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   740
    "
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   741
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   742
    "
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   743
     |t|
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   744
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   745
     t := Time now.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   746
     Transcript showCR:t.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   747
     Transcript showCR:(t subtractMinutes:60).
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   748
    "
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   749
!
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   750
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   751
subtractSeconds:numberOfSeconds
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   752
    "return a new instance of myself, numberOfSeconds before."
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   753
3476
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   754
    ^ self species basicNew 
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   755
        setMilliseconds:(self getMilliseconds - (numberOfSeconds * 1000))
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   756
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   757
    "
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   758
     |t|
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   759
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   760
     t := Timestamp now.
3476
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   761
     Transcript showCR:t.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   762
     Transcript showCR:(t subtractSeconds:60).
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   763
    "
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   764
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   765
    "
3476
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   766
     |t|
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   767
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   768
     t := Time now.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   769
     Transcript showCR:t.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   770
     Transcript showCR:(t subtractSeconds:60).
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   771
    "
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   772
!
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   773
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   774
subtractTime:timeAmount
3476
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   775
    "return a new instance of myself, timeAmount seconds before myself.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   776
     Provided for ST-80 compatibility.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   777
     WARNING:
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   778
        SubtractTime is a bad name - it does not add a time, but expects
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   779
        a numberOfSeconds as argument. 
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   780
        Use any of addSeconds/addHours etc. to make things clear"
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   781
6888
d75cbe2e8ef7 addTime / subtractTime handle non-Number argument
Claus Gittinger <cg@exept.de>
parents: 6795
diff changeset
   782
    timeAmount isNumber ifFalse:[
d75cbe2e8ef7 addTime / subtractTime handle non-Number argument
Claus Gittinger <cg@exept.de>
parents: 6795
diff changeset
   783
        ^ self subtractSeconds:(timeAmount asSeconds).
d75cbe2e8ef7 addTime / subtractTime handle non-Number argument
Claus Gittinger <cg@exept.de>
parents: 6795
diff changeset
   784
    ].
3476
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   785
    ^ self subtractSeconds:timeAmount
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   786
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   787
! !
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   788
5573
efd0dc6578ac #-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 5548
diff changeset
   789
!AbstractTime methodsFor:'comparing'!
efd0dc6578ac #-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 5548
diff changeset
   790
efd0dc6578ac #-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 5548
diff changeset
   791
< aTime
efd0dc6578ac #-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 5548
diff changeset
   792
    "return true if the receiver is before the argument"
efd0dc6578ac #-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 5548
diff changeset
   793
efd0dc6578ac #-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 5548
diff changeset
   794
    ^ self getMilliseconds < aTime getMilliseconds
efd0dc6578ac #-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 5548
diff changeset
   795
efd0dc6578ac #-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 5548
diff changeset
   796
    "Modified: 3.7.1996 / 13:10:17 / cg"
efd0dc6578ac #-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 5548
diff changeset
   797
!
efd0dc6578ac #-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 5548
diff changeset
   798
efd0dc6578ac #-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 5548
diff changeset
   799
> aTime
efd0dc6578ac #-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 5548
diff changeset
   800
    "return true if the receiver is after the argument"
efd0dc6578ac #-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 5548
diff changeset
   801
efd0dc6578ac #-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 5548
diff changeset
   802
    ^ self getMilliseconds > aTime getMilliseconds
efd0dc6578ac #-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 5548
diff changeset
   803
efd0dc6578ac #-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 5548
diff changeset
   804
    "Modified: 1.7.1996 / 15:24:38 / cg"
efd0dc6578ac #-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 5548
diff changeset
   805
! !
efd0dc6578ac #-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 5548
diff changeset
   806
8200
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   807
!AbstractTime methodsFor:'converting'!
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   808
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   809
asAbsoluteTime
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   810
    "deprecated, use #asTimestamp"
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   811
    <resource:#obsolete>
8200
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   812
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   813
    ^ self asTimestamp
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   814
!
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   815
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   816
asTimestamp
8200
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   817
    ^ self subclassResponsibility
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   818
! !
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   819
4649
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
   820
!AbstractTime methodsFor:'printing & storing'!
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
   821
4844
6938f0df31f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4841
diff changeset
   822
addPrintBindingsTo:aDictionary
8111
67347b7e3e69 print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents: 7672
diff changeset
   823
    "private print support: add bindings for printing to aDictionary."
67347b7e3e69 print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents: 7672
diff changeset
   824
67347b7e3e69 print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents: 7672
diff changeset
   825
    self addPrintBindingsTo:aDictionary language:nil
67347b7e3e69 print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents: 7672
diff changeset
   826
!
67347b7e3e69 print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents: 7672
diff changeset
   827
67347b7e3e69 print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents: 7672
diff changeset
   828
addPrintBindingsTo:aDictionary language:languageOrNil
67347b7e3e69 print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents: 7672
diff changeset
   829
    "private print support: add bindings for printing to aDictionary.
67347b7e3e69 print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents: 7672
diff changeset
   830
     languageOrNil can only be #en or nil for the current language."
4844
6938f0df31f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4841
diff changeset
   831
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   832
    |hours minutes seconds millis usHours ampm s zone tzDelta|
4844
6938f0df31f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4841
diff changeset
   833
6938f0df31f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4841
diff changeset
   834
    hours := self hours.
6938f0df31f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4841
diff changeset
   835
    minutes := self minutes.
6938f0df31f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4841
diff changeset
   836
    seconds := self seconds.
6938f0df31f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4841
diff changeset
   837
    millis := self milliseconds.
5968
4832ed93f0b4 preps for timeZone
Claus Gittinger <cg@exept.de>
parents: 5964
diff changeset
   838
    zone := self timeZoneName.
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   839
    tzDelta := self timeZoneDeltaInMinutes.
4844
6938f0df31f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4841
diff changeset
   840
6419
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   841
    ampm := self meridianAbbreviation.
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   842
    usHours := self hour12.
4844
6938f0df31f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4841
diff changeset
   843
6938f0df31f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4841
diff changeset
   844
    aDictionary at:$H put:(s := hours printString).
6938f0df31f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4841
diff changeset
   845
    aDictionary at:$h put:(s leftPaddedTo:2 with:$0).
6938f0df31f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4841
diff changeset
   846
    aDictionary at:$U put:(s := usHours printString).
6938f0df31f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4841
diff changeset
   847
    aDictionary at:$u put:(s leftPaddedTo:2 with:$0).
6938f0df31f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4841
diff changeset
   848
    aDictionary at:$M put:(s := minutes printString).
6938f0df31f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4841
diff changeset
   849
    aDictionary at:$m put:(s leftPaddedTo:2 with:$0).
6938f0df31f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4841
diff changeset
   850
    aDictionary at:$S put:(s := seconds printString).
6938f0df31f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4841
diff changeset
   851
    aDictionary at:$s put:(s leftPaddedTo:2 with:$0).
6938f0df31f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4841
diff changeset
   852
    aDictionary at:$I put:(s := millis printString).
6938f0df31f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4841
diff changeset
   853
    aDictionary at:$i put:(s leftPaddedTo:3 with:$0).
4904
33d322c419ba more format strings for milliseconds.
Claus Gittinger <cg@exept.de>
parents: 4844
diff changeset
   854
    aDictionary at:#milli1 put:((millis // 100) printString).
33d322c419ba more format strings for milliseconds.
Claus Gittinger <cg@exept.de>
parents: 4844
diff changeset
   855
    aDictionary at:#milli2 put:((millis // 10) printStringLeftPaddedTo:2 with:$0).
4844
6938f0df31f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4841
diff changeset
   856
    aDictionary at:$t put:(seconds * minutes) printString.
6938f0df31f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4841
diff changeset
   857
    aDictionary at:$T put:(seconds * minutes * hours) printString.
6938f0df31f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4841
diff changeset
   858
    aDictionary at:$a put:ampm.
6938f0df31f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4841
diff changeset
   859
    aDictionary at:$A put:ampm asUppercase.
5968
4832ed93f0b4 preps for timeZone
Claus Gittinger <cg@exept.de>
parents: 5964
diff changeset
   860
    aDictionary at:$z put:zone.
4832ed93f0b4 preps for timeZone
Claus Gittinger <cg@exept.de>
parents: 5964
diff changeset
   861
    aDictionary at:$Z put:zone asUppercase.
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   862
9432
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
   863
    tzDelta == 0 ifTrue:[
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
   864
        s := 'Z'.
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
   865
    ] ifFalse:[
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
   866
        s := tzDelta < 0 ifTrue:[ '-' ] ifFalse:[ '+' ].
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
   867
        tzDelta := tzDelta abs.
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
   868
        s := s  , ((tzDelta // 60) printStringLeftPaddedTo:2 with:$0), 
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
   869
            ':' , ((tzDelta \\ 60) printStringLeftPaddedTo:2 with:$0).
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
   870
    ].
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   871
    aDictionary at:#TZD put:s
4844
6938f0df31f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4841
diff changeset
   872
!
6938f0df31f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4841
diff changeset
   873
4649
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
   874
printOn:aStream format:aFormatString
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
   875
    "print using a format string;
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
   876
     valid format items are:
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
   877
        %h      hours, 00..23 (i.e. european)  0-padded to length 2
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
   878
        %u      hours, 00..12 (i.e. us)        0-padded to length 2
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
   879
        %m      minutes, 00..59                0-padded to length 2
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
   880
        %s      seconds, 00..59                0-padded to length 2
4841
605413879f65 comment
Claus Gittinger <cg@exept.de>
parents: 4840
diff changeset
   881
        %i      milliseconds, 000..999         0-padded to length 3
4649
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
   882
        %a      am/pm
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
   883
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   884
     Timestamp only:
4844
6938f0df31f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4841
diff changeset
   885
        %day     day, 00..31                    0-padded to length 2
6938f0df31f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4841
diff changeset
   886
        %mon     month, 00..12                  0-padded to length 2
6938f0df31f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4841
diff changeset
   887
        %yr      year, 4 digits                 0-padded to length 4
6938f0df31f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4841
diff changeset
   888
4649
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
   889
     special:
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
   890
        %H      24-hours - unpadded
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
   891
        %U      12-hours - unpadded
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
   892
        %M      minutes - unpadded
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
   893
        %S      seconds - unpadded
4844
6938f0df31f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4841
diff changeset
   894
        %I      milliseconds - unpadded
4649
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
   895
        %A      AM/PM   - uppercase
4841
605413879f65 comment
Claus Gittinger <cg@exept.de>
parents: 4840
diff changeset
   896
605413879f65 comment
Claus Gittinger <cg@exept.de>
parents: 4840
diff changeset
   897
        %t      seconds within hour  (unpadded)
605413879f65 comment
Claus Gittinger <cg@exept.de>
parents: 4840
diff changeset
   898
        %T      seconds from midNight  (unpadded)
4844
6938f0df31f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4841
diff changeset
   899
7327
ab17eb5f11a6 printFormat
Claus Gittinger <cg@exept.de>
parents: 7294
diff changeset
   900
        %nth           - counting day-in-month (1->'st'; 2->'nd'; 3->'rd'; 4...->'th')      
ab17eb5f11a6 printFormat
Claus Gittinger <cg@exept.de>
parents: 7294
diff changeset
   901
        %weekDayNth    - counting day-in-week (1->'st'; 2->'nd'; 3->'rd'; 4...->'th')      
ab17eb5f11a6 printFormat
Claus Gittinger <cg@exept.de>
parents: 7294
diff changeset
   902
        %weekNth       - counting week-in-year (1->'st'; 2->'nd'; 3->'rd'; 4...->'th')      
ab17eb5f11a6 printFormat
Claus Gittinger <cg@exept.de>
parents: 7294
diff changeset
   903
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   904
     Timestamp only:
4844
6938f0df31f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4841
diff changeset
   905
        %Day    day - unpadded                    
6938f0df31f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4841
diff changeset
   906
        %Mon    month - unpadded                    
4649
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
   907
    "
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
   908
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
   909
    aStream nextPutAll:(self printStringFormat:aFormatString)
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
   910
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
   911
    "
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   912
     Timestamp now printOn:Transcript format:'%h:%m:%s'   . Transcript cr.      
4649
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
   913
     Time now printOn:Transcript format:'%h:%m:%s'   . Transcript cr.      
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
   914
     Time now printOn:Transcript format:'%H:%m:%s'   . Transcript cr.      
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
   915
     Time now printOn:Transcript format:'%u:%m:%s %a'. Transcript cr.   
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
   916
     Time now printOn:Transcript format:'%h:%m'      . Transcript cr. 
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
   917
     Time now printOn:Transcript format:'%H:%m %A'   . Transcript cr.
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
   918
     Time now printOn:Transcript format:'minutes:%M seconds:%S'   . Transcript cr.
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
   919
    "
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
   920
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
   921
    "Modified: 22.2.1996 / 16:58:30 / cg"
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
   922
!
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
   923
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
   924
printStringFormat:aFormatString
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
   925
    "print using a format string;
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
   926
     valid format items are:
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
   927
        %h      hours, 00..23 (i.e. european)  0-padded to length 2
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
   928
        %u      hours, 00..12 (i.e. us)        0-padded to length 2
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
   929
        %m      minutes, 00..59                0-padded to length 2
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
   930
        %s      seconds, 00..59                0-padded to length 2
4840
e97f4f2339d9 added milliseconds in printFormat
Claus Gittinger <cg@exept.de>
parents: 4835
diff changeset
   931
        %i      milliseconds, 000..999         0-padded to length 3
4649
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
   932
        %a      am/pm
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
   933
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   934
     Timestamp only:
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   935
        %(day)   day, 00..31                    0-padded to length 2
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   936
        %(month) month, 00..12                  0-padded to length 2
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   937
        %(year)  year, 4 digits                 0-padded to length 4
4844
6938f0df31f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4841
diff changeset
   938
4649
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
   939
     special:
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
   940
        %H      24-hours - unpadded
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
   941
        %U      12-hours - unpadded
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
   942
        %M      minutes - unpadded
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
   943
        %S      seconds - unpadded
4840
e97f4f2339d9 added milliseconds in printFormat
Claus Gittinger <cg@exept.de>
parents: 4835
diff changeset
   944
        %I      milliseconds, unpadded
4649
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
   945
        %A      AM/PM   - uppercase
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
   946
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
   947
        %t      seconds within hour  (unpadded)
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
   948
        %T      seconds from midNight  (unpadded)
4844
6938f0df31f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4841
diff changeset
   949
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   950
        %(TZD)  timeZone delta from UTC in the format +/-hh:mm  
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   951
4904
33d322c419ba more format strings for milliseconds.
Claus Gittinger <cg@exept.de>
parents: 4844
diff changeset
   952
        %milli1 milliseconds, truncated to 1/10th of a second 0..9         
33d322c419ba more format strings for milliseconds.
Claus Gittinger <cg@exept.de>
parents: 4844
diff changeset
   953
        %milli2 milliseconds, truncated to 1/100th of a second 00..99 0-padded to length 2        
33d322c419ba more format strings for milliseconds.
Claus Gittinger <cg@exept.de>
parents: 4844
diff changeset
   954
7327
ab17eb5f11a6 printFormat
Claus Gittinger <cg@exept.de>
parents: 7294
diff changeset
   955
        %nth           - counting day-in-month (1->'st'; 2->'nd'; 3->'rd'; 4...->'th')      
ab17eb5f11a6 printFormat
Claus Gittinger <cg@exept.de>
parents: 7294
diff changeset
   956
        %weekDayNth    - counting day-in-week (1->'st'; 2->'nd'; 3->'rd'; 4...->'th')      
ab17eb5f11a6 printFormat
Claus Gittinger <cg@exept.de>
parents: 7294
diff changeset
   957
        %weekNth       - counting week-in-year (1->'st'; 2->'nd'; 3->'rd'; 4...->'th')      
ab17eb5f11a6 printFormat
Claus Gittinger <cg@exept.de>
parents: 7294
diff changeset
   958
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   959
     Timestamp only:
4844
6938f0df31f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4841
diff changeset
   960
        %Day    day - unpadded                    
4929
ac174b74d54e month vs. mon
Claus Gittinger <cg@exept.de>
parents: 4905
diff changeset
   961
        %Month  month - unpadded                    
6795
519894240d97 more printFormats: yearOrDate (as in unix); dayPadded and monthPadded
penk
parents: 6419
diff changeset
   962
        %(yearOrTime)  year or time 5 digits    as in unix-ls:
519894240d97 more printFormats: yearOrDate (as in unix); dayPadded and monthPadded
penk
parents: 6419
diff changeset
   963
                                                year if it is not the current year;
519894240d97 more printFormats: yearOrDate (as in unix); dayPadded and monthPadded
penk
parents: 6419
diff changeset
   964
                                                time otherwise
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   965
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   966
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   967
     The ISO8601 printString are generated with:
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   968
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   969
       Year:
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   970
          YYYY (eg 1997)
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   971
                Date today printStringFormat:'%(year)'
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   972
                Timestamp now printStringFormat:'%(year)'  
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   973
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   974
       Year and month:
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   975
          YYYY-MM (eg 1997-07)
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   976
                Date today printStringFormat:'%(year)-%(month)'  
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   977
                Timestamp now printStringFormat:'%(year)-%(month)'  
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   978
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   979
       Complete date:
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   980
          YYYY-MM-DD (eg 1997-07-16)
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   981
                Date today printStringFormat:'%(year)-%(month)-%(day)'    
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   982
                Timestamp now printStringFormat:'%(year)-%(month)-%(day)'  
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   983
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   984
       Complete date plus hours and minutes:
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   985
          YYYY-MM-DDThh:mmTZD (eg 1997-07-16T19:20+01:00)
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   986
                Timestamp now printStringFormat:'%(year)-%(month)-%(day)T%h:%m%(TZD)'  
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   987
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   988
       Complete date plus hours, minutes and seconds:
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   989
          YYYY-MM-DDThh:mm:ssTZD (eg 1997-07-16T19:20:30+01:00)
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   990
                Timestamp now printStringFormat:'%(year)-%(month)-%(day)T%h:%m:%s%(TZD)'  
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   991
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   992
       Complete date plus hours, minutes, seconds and a decimal fraction of a second
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   993
          YYYY-MM-DDThh:mm:ss.sTZD (eg 1997-07-16T19:20:30.45+01:00)
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   994
                Timestamp now printStringFormat:'%(year)-%(month)-%(day)T%h:%m:%s.%(milli2)%(TZD)'  
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   995
4649
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
   996
    "
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
   997
4844
6938f0df31f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4841
diff changeset
   998
    |dict|
4649
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
   999
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1000
    dict := IdentityDictionary new.
4844
6938f0df31f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4841
diff changeset
  1001
    self addPrintBindingsTo:dict.
4649
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1002
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1003
    ^ (aFormatString expandPlaceholdersWith:dict)
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1004
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1005
    "
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
  1006
     Timestamp now printStringFormat:'%U:%m:%s %a'   
4649
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1007
     Time now printStringFormat:'%U:%m:%s %a'   
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1008
4844
6938f0df31f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4841
diff changeset
  1009
     Time now printStringFormat:'%h:%m:%s'      
4649
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1010
     Time now printStringFormat:'%H:%m:%s'      
4844
6938f0df31f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4841
diff changeset
  1011
     Time now printStringFormat:'%H:%m:%s.%i'           
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
  1012
     Timestamp now printStringFormat:'%H:%m:%s.%i'   
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
  1013
     Timestamp now printStringFormat:'%H:%m:%s.%(milli1)'   
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
  1014
     Timestamp now printStringFormat:'%H:%m:%s.%(milli2)'     
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
  1015
     Timestamp now printStringFormat:'%(day)-%(month)-%(year) :%m:%s'       
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
  1016
     Timestamp now printStringFormat:'%(day)-%(monthName)-%(year) :%m:%s'       
4649
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1017
     Time now printStringFormat:'%u:%m:%s %a'   
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1018
     Time now printStringFormat:'%h:%m'         
4844
6938f0df31f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4841
diff changeset
  1019
     Time now printStringFormat:'%h:%m'         
4649
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1020
     Time now printStringFormat:'%H:%m %A'     
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1021
     Time now printStringFormat:'%m minutes after %U %a'     
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1022
     Time now printStringFormat:'%t seconds after %U %a'     
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1023
     Time now printStringFormat:'%T seconds from midNight'     
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1024
    "
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1025
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1026
    "Modified: 22.2.1996 / 16:58:30 / cg"
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1027
! !
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1028
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1029
!AbstractTime methodsFor:'private'!
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
  1030
1500
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1031
fromOSTime:osTime
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1032
    "set my time, from operatingSystems time parts"
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
  1033
1500
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1034
    ^ self subclassResponsibility
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1035
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1036
    "Modified: 1.7.1996 / 15:09:44 / cg"
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
  1037
!
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
  1038
1500
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1039
getMilliseconds
8200
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
  1040
    "get the milliseconds since some point of time in the past.
1500
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1041
     Since I am abstract (not knowing how the time is actually
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1042
     represented), this must be done by a concrete class."
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1043
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1044
    ^ self subclassResponsibility
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1045
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1046
    "Created: 1.7.1996 / 14:16:49 / cg"
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1047
!
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1048
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1049
getSeconds
8200
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
  1050
    "get the seconds since some point of time in the past.
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1051
     Since I am abstract (not knowing how the time is actually
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1052
     represented), this must be done by a concrete class."
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
  1053
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1054
    ^ self subclassResponsibility
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1055
!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1056
1500
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1057
setMilliseconds:millis
8200
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
  1058
    "set the milliseconds since some point of time in the past.
1500
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1059
     Since I am abstract (not knowing how the time is actually
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1060
     represented), this must be done by a concrete class."
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1061
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1062
    ^ self subclassResponsibility
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1063
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1064
    "Created: 1.7.1996 / 14:17:00 / cg"
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1065
!
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1066
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1067
setSeconds:secs
8200
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
  1068
    "set the seconds since some point of time in the past.
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1069
     Since I am abstract (not knowing how the time is actually
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1070
     represented), this must be done by a concrete class."
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1071
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1072
    ^ self subclassResponsibility
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
  1073
! !
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
  1074
2310
2cb1366e0eb3 Correct name: #secondDay --> #secondInDay.
Stefan Vogel <sv@exept.de>
parents: 1500
diff changeset
  1075
!AbstractTime class methodsFor:'documentation'!
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
  1076
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1077
version
9926
5bfe280953b9 *** empty log message ***
Michael Beyl <mb@exept.de>
parents: 9449
diff changeset
  1078
    ^ '$Header: /cvs/stx/stx/libbasic/AbstractTime.st,v 1.54 2006-09-18 12:46:39 mb Exp $'
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
  1079
! !