AbstractTime.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Wed, 03 Jun 2015 21:55:34 +0100
branchjv
changeset 18470 9e4db770f8f5
parent 18120 e3a375d5f6a8
child 18457 214d760f8247
permissions -rw-r--r--
Optimize for fast-path in String >> at: Avoid jumps in String >> at: for common case the receiver is an instance of String and thus has no instance variables. Similar as fix 877a8f1b326d for Arrays.
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
"
5548
eead51e4752e added #weekInYear query
Claus Gittinger <cg@exept.de>
parents: 5191
diff changeset
    12
"{ Package: 'stx:libbasic' }"
eead51e4752e added #weekInYear query
Claus Gittinger <cg@exept.de>
parents: 5191
diff changeset
    13
17400
2aad82c1d66c class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 17195
diff changeset
    14
"{ NameSpace: Smalltalk }"
2aad82c1d66c class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 17195
diff changeset
    15
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
    16
Magnitude subclass:#AbstractTime
7258
9ccdbee7d1ad method category rename
Claus Gittinger <cg@exept.de>
parents: 7010
diff changeset
    17
	instanceVariableNames:''
9ccdbee7d1ad method category rename
Claus Gittinger <cg@exept.de>
parents: 7010
diff changeset
    18
	classVariableNames:''
9ccdbee7d1ad method category rename
Claus Gittinger <cg@exept.de>
parents: 7010
diff changeset
    19
	poolDictionaries:''
7672
46f206594db3 Category change
Stefan Vogel <sv@exept.de>
parents: 7327
diff changeset
    20
	category:'Magnitude-Time'
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
    21
!
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
    22
2310
2cb1366e0eb3 Correct name: #secondDay --> #secondInDay.
Stefan Vogel <sv@exept.de>
parents: 1500
diff changeset
    23
!AbstractTime class methodsFor:'documentation'!
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
    24
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
    25
copyright
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
    26
"
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
    27
 COPYRIGHT (c) 1995 by Claus Gittinger
7010
13fcdfdc95b1 add methods for squeak compatibility
penk
parents: 7007
diff changeset
    28
              All Rights Reserved
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
    29
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
    30
 This software is furnished under a license and may be used
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
    31
 only in accordance with the terms of that license and with the
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
    32
 inclusion of the above copyright notice.   This software may not
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
    33
 be provided or otherwise made available to, or used by, any
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
    34
 other person.  No title to or ownership of the software is
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
    35
 hereby transferred.
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
    36
"
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
    37
!
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
    38
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
    39
documentation
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
    40
"
1500
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
    41
    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
    42
    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
    43
    There are no instances of this class in the system.
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
    44
    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
    45
1295
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 1282
diff changeset
    46
    [author:]
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 1282
diff changeset
    47
        Claus Gittinger
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 1282
diff changeset
    48
1282
3f5eda57c516 commentary
Claus Gittinger <cg@exept.de>
parents: 1227
diff changeset
    49
    [See also:]
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
    50
        Time Date Timestamp
1282
3f5eda57c516 commentary
Claus Gittinger <cg@exept.de>
parents: 1227
diff changeset
    51
        Delay ProcessorScheduler
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
    52
"
6172
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
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    55
iso8601Format
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    56
"
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    57
  Abstract
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    58
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    59
    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
    60
    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
    61
    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
    62
    most requirements. 
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
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    65
  Formats
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    66
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    67
    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
    68
    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
    69
    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
    70
    of comparing two dates with different precisions.
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    71
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    72
    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
    73
    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
    74
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    75
       Year:
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    76
          YYYY (eg 1997)
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    77
       Year and month:
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    78
          YYYY-MM (eg 1997-07)
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    79
       Complete date:
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    80
          YYYY-MM-DD (eg 1997-07-16)
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    81
       Complete date plus hours and minutes:
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    82
          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
    83
       Complete date plus hours, minutes and seconds:
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    84
          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
    85
       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
    86
    second
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    87
          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
    88
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    89
    where:
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    90
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    91
         YYYY = four-digit year
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    92
         MM   = two-digit month (01=January, etc.)
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    93
         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
    94
         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
    95
         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
    96
         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
    97
         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
    98
         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
    99
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   100
    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
   101
    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
   102
    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
   103
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   104
    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
   105
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   106
       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
   107
       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
   108
         '+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
   109
         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
   110
         'mm' minutes behind UTC. 
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   111
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   112
    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
   113
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   114
  The ISO8601 printString are generated with:
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   115
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   116
       Year:
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   117
          YYYY (eg 1997)
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   118
                Date today printStringFormat:'%(year)'
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   119
                Timestamp now printStringFormat:'%(year)'  
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   120
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   121
       Year and month:
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   122
          YYYY-MM (eg 1997-07)
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   123
                Date today printStringFormat:'%(year)-%(month)'  
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   124
                Timestamp now printStringFormat:'%(year)-%(month)'  
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   125
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   126
       Complete date:
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   127
          YYYY-MM-DD (eg 1997-07-16)
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   128
                Date today printStringFormat:'%(year)-%(month)-%(day)'    
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   129
                Timestamp now printStringFormat:'%(year)-%(month)-%(day)'  
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   130
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   131
       Complete date plus hours and minutes:
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   132
          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
   133
                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
   134
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   135
       Complete date plus hours, minutes and seconds:
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   136
          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
   137
                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
   138
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   139
       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
   140
          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
   141
                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
   142
"
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
   143
! !
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
   144
2310
2cb1366e0eb3 Correct name: #secondDay --> #secondInDay.
Stefan Vogel <sv@exept.de>
parents: 1500
diff changeset
   145
!AbstractTime class methodsFor:'instance creation'!
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
   146
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   147
dateAndTimeNow
1227
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   148
    "return an array filled with the current date and time.
16982
c37260d6ff78 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16941
diff changeset
   149
     As these provide no timezone info, this should be only used for user interface purposes.
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   150
     See also: Date today / Time now / Timestamp now."
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
   151
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   152
    ^ Array with:(Date today) with:(Time now)
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
   153
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
   154
    "
16982
c37260d6ff78 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16941
diff changeset
   155
     Time dateAndTimeNow       
c37260d6ff78 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16941
diff changeset
   156
     Date dateAndTimeNow       
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
   157
    "
1227
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   158
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   159
    "Modified: 19.4.1996 / 15:23:37 / cg"
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   160
!
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
   161
9432
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
   162
epoch
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
   163
    "answer the time when we start counting"
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
    ^ self new setSeconds:0
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
   166
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
   167
    "
16982
c37260d6ff78 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16941
diff changeset
   168
     Timestamp epoch
c37260d6ff78 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16941
diff changeset
   169
     Time epoch     
9432
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
   170
    "
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
   171
!
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
   172
1227
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   173
now
16982
c37260d6ff78 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16941
diff changeset
   174
    "return an instance of myself representing this moment with second precision.
c37260d6ff78 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16941
diff changeset
   175
     Timestamps will redefine this to always return millisecond precision."
1227
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   176
1500
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
   177
    ^ self basicNew fromOSTime:(OperatingSystem getOSTime)
1227
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   178
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   179
    "
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   180
     Timestamp now   
1227
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   181
     Time now   
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
1500
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
   184
    "Modified: 1.7.1996 / 15:20:10 / cg"
13233
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
   185
!
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
   186
16941
78358165ed6b class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16934
diff changeset
   187
nowWithMilliseconds
16982
c37260d6ff78 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16941
diff changeset
   188
    "return an instance of myself representing this moment with millisecond precision."
16941
78358165ed6b class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16934
diff changeset
   189
78358165ed6b class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16934
diff changeset
   190
    ^ self basicNew fromOSTimeWithMilliseconds:(OperatingSystem getOSTime)
78358165ed6b class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16934
diff changeset
   191
78358165ed6b class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16934
diff changeset
   192
    "
78358165ed6b class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16934
diff changeset
   193
     Timestamp now   
78358165ed6b class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16934
diff changeset
   194
     Time now
78358165ed6b class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16934
diff changeset
   195
     Time nowWithMilliseconds
78358165ed6b class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16934
diff changeset
   196
    "
78358165ed6b class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16934
diff changeset
   197
78358165ed6b class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16934
diff changeset
   198
    "Modified: 1.7.1996 / 15:20:10 / cg"
78358165ed6b class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16934
diff changeset
   199
!
78358165ed6b class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16934
diff changeset
   200
13233
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
   201
utcNow
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
   202
    "return an instance of myself representing this momentin the UTC timezone."
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
   203
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
   204
    ^ self subclassResponsibility
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
   205
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
   206
    "
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
   207
     Timestamp utcNow   
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
   208
     Timestamp utcNow
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
   209
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
   210
     Time now   
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
   211
     Time utcNow   
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
   212
    "
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
   213
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
   214
    "Modified: 1.7.1996 / 15:20:10 / cg"
1227
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   215
! !
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   216
7294
c4e6d095a150 category changes
Claus Gittinger <cg@exept.de>
parents: 7261
diff changeset
   217
!AbstractTime class methodsFor:'Compatibility-Squeak'!
7007
9af8cc2f82a4 totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents: 6888
diff changeset
   218
9432
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
   219
dateAndTimeFromSeconds:secondCount
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
   220
    "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
   221
9429
173bcd493d7c Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents: 8586
diff changeset
   222
    |timestamp|
173bcd493d7c Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents: 8586
diff changeset
   223
173bcd493d7c Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents: 8586
diff changeset
   224
"   
173bcd493d7c Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents: 8586
diff changeset
   225
    secondsBetween1901and1970 := 
9432
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
   226
        (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
   227
        *  (24 * 60 * 60)
173bcd493d7c Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents: 8586
diff changeset
   228
"
173bcd493d7c Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents: 8586
diff changeset
   229
9432
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
   230
    "stc cannot make large integers"
9449
6ba774be6aa1 stc can compile large integers!
Stefan Vogel <sv@exept.de>
parents: 9432
diff changeset
   231
    timestamp := Timestamp fromSeconds:secondCount - 2177452800.
7007
9af8cc2f82a4 totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents: 6888
diff changeset
   232
    ^ Array
9429
173bcd493d7c Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents: 8586
diff changeset
   233
        with: (timestamp asDate)
173bcd493d7c Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents: 8586
diff changeset
   234
        with: (timestamp asTime)
1227
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   235
7007
9af8cc2f82a4 totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents: 6888
diff changeset
   236
    "
9429
173bcd493d7c Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents: 8586
diff changeset
   237
     Timestamp dateAndTimeFromSeconds: (Time primSecondsClock) 
7007
9af8cc2f82a4 totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents: 6888
diff changeset
   238
     Time dateAndTimeFromSeconds: (Time totalSeconds) 
9af8cc2f82a4 totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents: 6888
diff changeset
   239
     Date dateAndTimeFromSeconds: (Time totalSeconds)
9af8cc2f82a4 totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents: 6888
diff changeset
   240
    "
9af8cc2f82a4 totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents: 6888
diff changeset
   241
!
9af8cc2f82a4 totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents: 6888
diff changeset
   242
11528
a617f1faef7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11518
diff changeset
   243
milliseconds:msTime1 since:msTime2
a617f1faef7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11518
diff changeset
   244
    "return the number of milliseconds between two
a617f1faef7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11518
diff changeset
   245
     millisecond time values, compensating for roll-over.
a617f1faef7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11518
diff changeset
   246
     The same as millisecondsBetween:and: for Squeak compatibility."
a617f1faef7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11518
diff changeset
   247
a617f1faef7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11518
diff changeset
   248
    ^ OperatingSystem millisecondTimeDeltaBetween:msTime1 and:msTime2
a617f1faef7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11518
diff changeset
   249
!
a617f1faef7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11518
diff changeset
   250
9926
5bfe280953b9 *** empty log message ***
Michael Beyl <mb@exept.de>
parents: 9449
diff changeset
   251
millisecondsSince: lastTime
5bfe280953b9 *** empty log message ***
Michael Beyl <mb@exept.de>
parents: 9449
diff changeset
   252
        "Answer the elapsed time since last recorded in milliseconds.
5bfe280953b9 *** empty log message ***
Michael Beyl <mb@exept.de>
parents: 9449
diff changeset
   253
        Compensate for rollover."
5bfe280953b9 *** empty log message ***
Michael Beyl <mb@exept.de>
parents: 9449
diff changeset
   254
5bfe280953b9 *** empty log message ***
Michael Beyl <mb@exept.de>
parents: 9449
diff changeset
   255
        ^self milliseconds: self millisecondClockValue since: lastTime
5bfe280953b9 *** empty log message ***
Michael Beyl <mb@exept.de>
parents: 9449
diff changeset
   256
!
5bfe280953b9 *** empty log message ***
Michael Beyl <mb@exept.de>
parents: 9449
diff changeset
   257
7007
9af8cc2f82a4 totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents: 6888
diff changeset
   258
primSecondsClock
9429
173bcd493d7c Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents: 8586
diff changeset
   259
    "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
   260
173bcd493d7c Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents: 8586
diff changeset
   261
    ^ Timestamp now utcSecondsSince1901
1227
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   262
9429
173bcd493d7c Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents: 8586
diff changeset
   263
    "                                                 
173bcd493d7c Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents: 8586
diff changeset
   264
     Timestamp primSecondsClock 
173bcd493d7c Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents: 8586
diff changeset
   265
    "
1227
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   266
! !
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   267
7294
c4e6d095a150 category changes
Claus Gittinger <cg@exept.de>
parents: 7261
diff changeset
   268
!AbstractTime class methodsFor:'Compatibility-VW'!
7007
9af8cc2f82a4 totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents: 6888
diff changeset
   269
9af8cc2f82a4 totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents: 6888
diff changeset
   270
totalSeconds
9429
173bcd493d7c Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents: 8586
diff changeset
   271
    "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
   272
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   273
    ^ Timestamp now utcSecondsSince1901
7007
9af8cc2f82a4 totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents: 6888
diff changeset
   274
! !
9af8cc2f82a4 totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents: 6888
diff changeset
   275
11130
fb6ebdb8c2a1 conversion errors
Claus Gittinger <cg@exept.de>
parents: 10907
diff changeset
   276
!AbstractTime class methodsFor:'error handling'!
fb6ebdb8c2a1 conversion errors
Claus Gittinger <cg@exept.de>
parents: 10907
diff changeset
   277
fb6ebdb8c2a1 conversion errors
Claus Gittinger <cg@exept.de>
parents: 10907
diff changeset
   278
conversionErrorSignal
fb6ebdb8c2a1 conversion errors
Claus Gittinger <cg@exept.de>
parents: 10907
diff changeset
   279
    "return the signal used for conversion error handling"
fb6ebdb8c2a1 conversion errors
Claus Gittinger <cg@exept.de>
parents: 10907
diff changeset
   280
fb6ebdb8c2a1 conversion errors
Claus Gittinger <cg@exept.de>
parents: 10907
diff changeset
   281
    ^ TimeConversionError
fb6ebdb8c2a1 conversion errors
Claus Gittinger <cg@exept.de>
parents: 10907
diff changeset
   282
! !
fb6ebdb8c2a1 conversion errors
Claus Gittinger <cg@exept.de>
parents: 10907
diff changeset
   283
13701
46009307d8e3 added: defaultFormatString
ca
parents: 13233
diff changeset
   284
!AbstractTime class methodsFor:'format strings'!
46009307d8e3 added: defaultFormatString
ca
parents: 13233
diff changeset
   285
46009307d8e3 added: defaultFormatString
ca
parents: 13233
diff changeset
   286
defaultFormatString
46009307d8e3 added: defaultFormatString
ca
parents: 13233
diff changeset
   287
    ^ '%h:%m:%s'
46009307d8e3 added: defaultFormatString
ca
parents: 13233
diff changeset
   288
! !
46009307d8e3 added: defaultFormatString
ca
parents: 13233
diff changeset
   289
7258
9ccdbee7d1ad method category rename
Claus Gittinger <cg@exept.de>
parents: 7010
diff changeset
   290
!AbstractTime class methodsFor:'private-instance creation'!
1227
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   291
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   292
fromOSTime:osTime
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   293
    "return a time, representing the time given by the operatingSystem time.
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   294
     Not meant for public use."
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   295
1500
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
   296
    ^ self basicNew fromOSTime:osTime.
418
claus
parents: 384
diff changeset
   297
1500
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
   298
    "Modified: 1.7.1996 / 15:09:54 / cg"
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
   299
!
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
   300
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   301
fromSeconds:seconds
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   302
    "return an instance that is constructed from seconds.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   303
     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
   304
     getSeconds, possibly adding/subtracting to that. 
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   305
     Never depend on any specific interpretation of the seconds,
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   306
     since it depends on how the OperatingSystem counts time
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   307
     (some start at 1900, others with 1970 ...)"
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
   308
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   309
   ^ self basicNew setSeconds:seconds
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
   310
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
   311
    "
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   312
     Time fromSeconds:0             should return midnight
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   313
     Timestamp fromSeconds:0     on UNIX: returns 1st. Jan 1970
1227
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   314
                                    on others: dont know
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   315
     (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
   316
        getSeconds                  on UNIX: returns 0
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
   317
                                    on others: dont know
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   318
    "
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   319
1500
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
   320
    "Modified: 1.7.1996 / 13:39:30 / cg"
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
   321
! !
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
   322
2310
2cb1366e0eb3 Correct name: #secondDay --> #secondInDay.
Stefan Vogel <sv@exept.de>
parents: 1500
diff changeset
   323
!AbstractTime class methodsFor:'queries'!
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   324
15684
4c4bc53e32c8 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 14494
diff changeset
   325
microsecondClockValue
4c4bc53e32c8 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 14494
diff changeset
   326
    "return microseconds seconds of now"
4c4bc53e32c8 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 14494
diff changeset
   327
4c4bc53e32c8 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 14494
diff changeset
   328
    ^ OperatingSystem getMicrosecondTime
4c4bc53e32c8 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 14494
diff changeset
   329
4c4bc53e32c8 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 14494
diff changeset
   330
    "
4c4bc53e32c8 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 14494
diff changeset
   331
     Time microsecondClockValue
4c4bc53e32c8 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 14494
diff changeset
   332
    "
4c4bc53e32c8 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 14494
diff changeset
   333
4c4bc53e32c8 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 14494
diff changeset
   334
    "
4c4bc53e32c8 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 14494
diff changeset
   335
     |t1 t2 overhead|
4c4bc53e32c8 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 14494
diff changeset
   336
4c4bc53e32c8 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 14494
diff changeset
   337
     t1 := Time microsecondClockValue.
4c4bc53e32c8 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 14494
diff changeset
   338
     t2 := Time microsecondClockValue.
4c4bc53e32c8 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 14494
diff changeset
   339
     overhead := t2 - t1.  
4c4bc53e32c8 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 14494
diff changeset
   340
4c4bc53e32c8 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 14494
diff changeset
   341
     t1 := Time microsecondClockValue.
4c4bc53e32c8 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 14494
diff changeset
   342
     100 factorial.
4c4bc53e32c8 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 14494
diff changeset
   343
     t2 := Time microsecondClockValue.
4c4bc53e32c8 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 14494
diff changeset
   344
     t2 - t1 - overhead        
4c4bc53e32c8 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 14494
diff changeset
   345
    "
4c4bc53e32c8 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 14494
diff changeset
   346
!
4c4bc53e32c8 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 14494
diff changeset
   347
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   348
millisecondClockValue
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   349
    "return the millisecond clock - since this one overruns
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   350
     regularly, use the value only for short timing deltas.
5730
b377ec6357e7 comment
Claus Gittinger <cg@exept.de>
parents: 5573
diff changeset
   351
     Also remember that it wraps when comparing these values."
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   352
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   353
    ^ OperatingSystem getMillisecondTime.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   354
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   355
    "
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   356
     Time millisecondClockValue 
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   357
    "
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   358
!
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   359
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   360
secondClock
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   361
    "return seconds of now - for GNU-ST compatibility"
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   362
1500
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
   363
    ^ OperatingSystem getOSTime // 1000
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   364
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   365
    "
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   366
     AbstractTime secondClock    
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   367
    "
1500
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
   368
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
   369
    "Modified: 1.7.1996 / 15:20:14 / cg"
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   370
! !
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   371
2310
2cb1366e0eb3 Correct name: #secondDay --> #secondInDay.
Stefan Vogel <sv@exept.de>
parents: 1500
diff changeset
   372
!AbstractTime class methodsFor:'timing evaluations'!
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   373
12831
97be4636cf07 added: #microsecondsToRun:
Stefan Vogel <sv@exept.de>
parents: 12662
diff changeset
   374
microsecondsToRun:aBlock
16673
38e6f4c80e3a fixed buggy copy pasta comment
az
parents: 16505
diff changeset
   375
    "evaluate the argument, aBlock; return the number of microseconds it took"
12831
97be4636cf07 added: #microsecondsToRun:
Stefan Vogel <sv@exept.de>
parents: 12662
diff changeset
   376
97be4636cf07 added: #microsecondsToRun:
Stefan Vogel <sv@exept.de>
parents: 12662
diff changeset
   377
    |startTime endTime|
97be4636cf07 added: #microsecondsToRun:
Stefan Vogel <sv@exept.de>
parents: 12662
diff changeset
   378
97be4636cf07 added: #microsecondsToRun:
Stefan Vogel <sv@exept.de>
parents: 12662
diff changeset
   379
    startTime := OperatingSystem getMicrosecondTime.
97be4636cf07 added: #microsecondsToRun:
Stefan Vogel <sv@exept.de>
parents: 12662
diff changeset
   380
    aBlock value.
97be4636cf07 added: #microsecondsToRun:
Stefan Vogel <sv@exept.de>
parents: 12662
diff changeset
   381
    endTime := OperatingSystem getMicrosecondTime.
97be4636cf07 added: #microsecondsToRun:
Stefan Vogel <sv@exept.de>
parents: 12662
diff changeset
   382
    ^ endTime - startTime
97be4636cf07 added: #microsecondsToRun:
Stefan Vogel <sv@exept.de>
parents: 12662
diff changeset
   383
97be4636cf07 added: #microsecondsToRun:
Stefan Vogel <sv@exept.de>
parents: 12662
diff changeset
   384
    "
97be4636cf07 added: #microsecondsToRun:
Stefan Vogel <sv@exept.de>
parents: 12662
diff changeset
   385
     Time microsecondsToRun:[1000 factorial]  
97be4636cf07 added: #microsecondsToRun:
Stefan Vogel <sv@exept.de>
parents: 12662
diff changeset
   386
    "
16673
38e6f4c80e3a fixed buggy copy pasta comment
az
parents: 16505
diff changeset
   387
38e6f4c80e3a fixed buggy copy pasta comment
az
parents: 16505
diff changeset
   388
    "Modified (comment): / 01-07-2014 / 15:57:13 / az"
12831
97be4636cf07 added: #microsecondsToRun:
Stefan Vogel <sv@exept.de>
parents: 12662
diff changeset
   389
!
97be4636cf07 added: #microsecondsToRun:
Stefan Vogel <sv@exept.de>
parents: 12662
diff changeset
   390
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   391
millisecondsToRun:aBlock
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   392
    "evaluate the argument, aBlock; return the number of milliseconds it took"
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   393
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   394
    |startTime endTime|
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   395
1476
02f69251f5bc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   396
    startTime := OperatingSystem getMillisecondTime.
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   397
    aBlock value.
1476
02f69251f5bc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   398
    endTime := OperatingSystem getMillisecondTime.
8586
a38e882affa5 take care of time-wrap in #millisecondsToRun:
Stefan Vogel <sv@exept.de>
parents: 8450
diff changeset
   399
    ^ self milliseconds:endTime since:startTime
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   400
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   401
    "
8586
a38e882affa5 take care of time-wrap in #millisecondsToRun:
Stefan Vogel <sv@exept.de>
parents: 8450
diff changeset
   402
     Time millisecondsToRun:[1000 factorial]  
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   403
    "
1476
02f69251f5bc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   404
02f69251f5bc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   405
    "Modified: 17.6.1996 / 16:57:37 / cg"
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   406
!
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   407
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   408
secondsToRun:aBlock
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   409
    "evaluate the argument, aBlock; return the number of seconds it took"
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   410
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   411
    |startTime endTime|
360
claus
parents: 275
diff changeset
   412
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   413
    startTime := self secondClock.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   414
    aBlock value.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   415
    endTime := self secondClock.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   416
    ^ endTime - startTime
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   417
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   418
    "
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   419
     Time secondsToRun:[1000 factorial]  
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   420
    "
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   421
! !
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   422
7261
f35fc9cee675 method category rename
Claus Gittinger <cg@exept.de>
parents: 7258
diff changeset
   423
!AbstractTime methodsFor:'Compatibility-ANSI'!
6419
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   424
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   425
hour12
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   426
    "return the hour (1..12)."
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   427
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   428
    ^ self hours - 1 \\ 12 + 1.
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   429
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   430
    "
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   431
     Time now hour12   
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   432
     Time now hour24   
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   433
     (Time hours:0 minutes:0 seconds:0) hour24   
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   434
     (Time hours:0 minutes:0 seconds:0) hour12   
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   435
     (Time hours:1 minutes:0 seconds:0) hour24   
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   436
     (Time hours:1 minutes:0 seconds:0) hour12   
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   437
     (Time hours:12 minutes:0 seconds:0) hour24 
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   438
     (Time hours:12 minutes:0 seconds:0) hour12   
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   439
     (Time hours:13 minutes:0 seconds:0) hour24 
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   440
     (Time hours:13 minutes:0 seconds:0) hour12   
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   441
     (Time hours:23 minutes:0 seconds:0) hour24 
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   442
     (Time hours:23 minutes:0 seconds:0) hour12   
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   443
     (Time hours:24 minutes:0 seconds:0) hour24 
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   444
     (Time hours:24 minutes:0 seconds:0) hour12   
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   445
    "
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   446
!
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   447
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   448
hour24
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   449
    "return the hour (0..23)."
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   450
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   451
    ^ self hours
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   452
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   453
    "
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   454
     Time now hour12   
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   455
     Time now hour24   
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   456
     (Time hours:0 minutes:0 seconds:0) hour24 
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   457
     (Time hours:0 minutes:0 seconds:0) hour12 
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   458
     (Time hours:1 minutes:0 seconds:0) hour24 
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   459
     (Time hours:1 minutes:0 seconds:0) hour12 
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   460
     (Time hours:12 minutes:0 seconds:0) hour24 
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   461
     (Time hours:12 minutes:0 seconds:0) hour12 
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   462
     (Time hours:13 minutes:0 seconds:0) hour24 
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   463
     (Time hours:13 minutes:0 seconds:0) hour12 
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   464
     (Time hours:23 minutes:0 seconds:0) hour24 
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   465
     (Time hours:23 minutes:0 seconds:0) hour12 
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   466
     (Time hours:24 minutes:0 seconds:0) hour24 
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   467
     (Time hours:24 minutes:0 seconds:0) hour12 
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   468
    "
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   469
!
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   470
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   471
meridianAbbreviation
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   472
    "am/pm"
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   473
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   474
    self hours // 12 == 0 ifTrue:[
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   475
        ^ 'am'.
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   476
    ] ifFalse:[
8200
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   477
        (self hours == 12 and:[self minutes == 0 and:[self seconds == 0]]) ifTrue:[
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   478
            ^ 'noon'
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   479
        ].
6419
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   480
        ^ 'pm'.
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   481
    ].
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   482
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   483
    "
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   484
     Time now meridianAbbreviation   
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   485
     (Time hours:0 minutes:0 seconds:0) meridianAbbreviation  
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   486
     (Time hours:11 minutes:59 seconds:59) meridianAbbreviation  
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   487
     (Time hours:12 minutes:0 seconds:0) meridianAbbreviation    
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   488
     (Time hours:12 minutes:0 seconds:1) meridianAbbreviation  
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   489
    "
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   490
! !
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   491
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   492
!AbstractTime methodsFor:'abstract'!
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
hours
8200
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   495
    "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
   496
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   497
    ^ self subclassResponsibility
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   498
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   499
    "
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   500
     Timestamp now hours 
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   501
     Time now hours 
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   502
    "
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   503
!
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   504
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   505
milliseconds
8200
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   506
    "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
   507
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   508
    ^ self subclassResponsibility
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   509
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   510
    "
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   511
     Timestamp now milliseconds 
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   512
     Time now milliseconds 
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   513
    "
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   514
!
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   515
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   516
minutes
8200
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   517
    "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
   518
7672
46f206594db3 Category change
Stefan Vogel <sv@exept.de>
parents: 7327
diff changeset
   519
    ^ self subclassResponsibility.
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   520
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   521
    "
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   522
     Timestamp now minutes 
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   523
     Time now minutes 
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   524
    "
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   525
!
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   526
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   527
seconds
8200
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   528
    "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
   529
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   530
    ^ self subclassResponsibility
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   531
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   532
    "
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   533
     Timestamp now seconds. 
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   534
     Time now seconds 
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   535
    "
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   536
! !
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   537
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   538
!AbstractTime methodsFor:'accessing'!
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   539
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   540
hourInDay
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   541
    "return the hours (0..23)"
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   542
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   543
    ^ self hours
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   544
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   545
    "
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   546
     Timestamp now hourInDay 
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   547
     Time now hourInDay 
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   548
    "
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
minuteInDay
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   552
    "return the minutes (0..59)"
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   553
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   554
    ^ self minutes.
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   555
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   556
    "
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   557
     Timestamp now minuteInDay 
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   558
     Time now minuteInDay 
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   559
    "
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   560
!
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   561
2310
2cb1366e0eb3 Correct name: #secondDay --> #secondInDay.
Stefan Vogel <sv@exept.de>
parents: 1500
diff changeset
   562
secondInDay
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   563
    "return the seconds (0..59)"
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   564
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   565
    ^ self seconds
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   566
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   567
    "
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   568
     Timestamp now secondInDay 
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   569
     Time now seconds 
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   570
    "
2310
2cb1366e0eb3 Correct name: #secondDay --> #secondInDay.
Stefan Vogel <sv@exept.de>
parents: 1500
diff changeset
   571
2cb1366e0eb3 Correct name: #secondDay --> #secondInDay.
Stefan Vogel <sv@exept.de>
parents: 1500
diff changeset
   572
    "Created: 22.10.1996 / 09:27:47 / stefan"
5548
eead51e4752e added #weekInYear query
Claus Gittinger <cg@exept.de>
parents: 5191
diff changeset
   573
!
eead51e4752e added #weekInYear query
Claus Gittinger <cg@exept.de>
parents: 5191
diff changeset
   574
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   575
timeZoneDeltaInMinutes
9432
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
   576
    "answer the number of minutes between local time and utc time.
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
   577
     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
   578
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   579
    ^ 0
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   580
!
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   581
5968
4832ed93f0b4 preps for timeZone
Claus Gittinger <cg@exept.de>
parents: 5964
diff changeset
   582
timeZoneName
16982
c37260d6ff78 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16941
diff changeset
   583
    ^ 'UTC'
c37260d6ff78 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16941
diff changeset
   584
!
c37260d6ff78 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16941
diff changeset
   585
c37260d6ff78 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16941
diff changeset
   586
utcOffset
c37260d6ff78 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16941
diff changeset
   587
    ^ 0
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   588
! !
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   589
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   590
!AbstractTime methodsFor:'arithmetic'!
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   591
10679
b4dd3412ce74 adding timeDurations to a timeStamp (double dispatch)
sr
parents: 10485
diff changeset
   592
+ aNumberOrTimeDuration
b4dd3412ce74 adding timeDurations to a timeStamp (double dispatch)
sr
parents: 10485
diff changeset
   593
    "Add aNumber numberOfSeconds or, if its a timeDuration, add its value"
8200
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   594
10679
b4dd3412ce74 adding timeDurations to a timeStamp (double dispatch)
sr
parents: 10485
diff changeset
   595
    ^ aNumberOrTimeDuration sumFromTimestamp:self.
b4dd3412ce74 adding timeDurations to a timeStamp (double dispatch)
sr
parents: 10485
diff changeset
   596
17015
f7c4867a3633 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16982
diff changeset
   597
"/    ^ self speciesNew 
10679
b4dd3412ce74 adding timeDurations to a timeStamp (double dispatch)
sr
parents: 10485
diff changeset
   598
"/        setMilliseconds:(self getMilliseconds + (aNumberOrTimeDuration * 1000) asInteger)
8200
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   599
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   600
    "
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   601
     Timestamp now to:(Timestamp now + 30) by:2 do:[:time|
8200
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   602
        Transcript showCR:time.
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   603
     ].
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   604
10679
b4dd3412ce74 adding timeDurations to a timeStamp (double dispatch)
sr
parents: 10485
diff changeset
   605
     (Timestamp now + 20)  -  Timestamp now  
b4dd3412ce74 adding timeDurations to a timeStamp (double dispatch)
sr
parents: 10485
diff changeset
   606
     (Timestamp now + 0.5)  -  Timestamp now  
b4dd3412ce74 adding timeDurations to a timeStamp (double dispatch)
sr
parents: 10485
diff changeset
   607
     (Timestamp now + (TimeDuration fromString:'1m 10s'))  -  Timestamp now  
11771
1c6251b7286d comment
Claus Gittinger <cg@exept.de>
parents: 11528
diff changeset
   608
     (Timestamp now + (10 seconds))  -  Timestamp now  
8200
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   609
    "
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   610
!
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   611
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   612
- aTimeOrNumberOfSeconds
8244
06543e00260e comment
Claus Gittinger <cg@exept.de>
parents: 8200
diff changeset
   613
    "return the delta in seconds between 2 times or subtract a number of seconds."
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   614
11515
d467ba9dc495 double dispatch for subtract (time - time; time - nr)
sr
parents: 11130
diff changeset
   615
    ^ aTimeOrNumberOfSeconds differenceFromTimestamp:self.
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   616
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   617
    "
11518
8b4cafbd318a double dispatch for time-difference
sr
parents: 11515
diff changeset
   618
     Timestamp now - 3600.  
11515
d467ba9dc495 double dispatch for subtract (time - time; time - nr)
sr
parents: 11130
diff changeset
   619
     Time now - 3600.   
11518
8b4cafbd318a double dispatch for time-difference
sr
parents: 11515
diff changeset
   620
     (Time now addSeconds:10) - Time now   
11515
d467ba9dc495 double dispatch for subtract (time - time; time - nr)
sr
parents: 11130
diff changeset
   621
     (TimeDuration fromString:'1.5hr') - 3600.   
d467ba9dc495 double dispatch for subtract (time - time; time - nr)
sr
parents: 11130
diff changeset
   622
     (TimeDuration fromString:'1.5hr') - (TimeDuration fromString:'1hr')   
8200
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   623
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   624
     |t1 t2|
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   625
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   626
     t1 := Timestamp now.
16407
67eeb7ae5eb8 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16365
diff changeset
   627
     Delay waitFor:10 seconds.
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   628
     t2 := Timestamp now.
3476
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   629
     Transcript showCR:('seconds passed: ' , (t2 - t1) printString).
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
6048
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   633
addDays:numberOfDays
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   634
    "return a new instance of myself, numberOfDays afterwards."
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   635
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   636
    ^ self addSeconds:(numberOfDays * (60 * 60 * 24))
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   637
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   638
    "
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   639
     |t|
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   640
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   641
     t := Timestamp now.
6048
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   642
     Transcript showCR:t.
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   643
     Transcript showCR:(t addDays:7)
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   644
    "
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   645
!
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   646
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   647
addHours:numberOfHours
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   648
    "return a new instance of myself, numberOfHours afterwards."
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   649
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   650
    ^ self addSeconds:(numberOfHours * (60 * 60))
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   651
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   652
    "
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   653
     |t|
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   654
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   655
     t := Timestamp now.
3476
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   656
     Transcript showCR:t.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   657
     Transcript showCR:(t addHours:12).
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   658
    "
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   659
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   660
    "
3476
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   661
     |t|
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   662
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   663
     t := Time now.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   664
     Transcript showCR:t.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   665
     Transcript showCR:(t addHours:12).
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   666
    "
6043
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   667
!
3476
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   668
6043
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   669
addMilliseconds:numberOfMilliSeconds
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   670
    "return a new instance of myself, numberOfMilliSeconds afterwards."
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   671
17015
f7c4867a3633 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16982
diff changeset
   672
    ^ self speciesNew 
6043
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   673
        setMilliseconds:(self getMilliseconds + numberOfMilliSeconds)
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   674
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   675
    "
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   676
     |t|
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
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.
6043
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   679
     Transcript showCR:t.
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   680
     Transcript showCR:(t addMilliseconds:100).
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   681
    "
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   682
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   683
    "
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   684
     |t|
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   685
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   686
     t := Time now.
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   687
     Transcript showCR:t.
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   688
     Transcript showCR:(t addMilliseconds:1000).
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   689
    "
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   690
!
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   691
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   692
addMinutes:numberOfMinutes
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   693
    "return a new instance of myself, numberOfMinutes afterwards."
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   694
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   695
    ^ self addSeconds:(numberOfMinutes * 60)
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   696
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   697
    "
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   698
     |t|
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   699
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   700
     t := Timestamp now.
3476
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 addMinutes:60).
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   703
    "
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   704
3476
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   705
    "
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   706
     |t|
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   707
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   708
     t := Time now.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   709
     Transcript showCR:t.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   710
     Transcript showCR:(t addMinutes:60).
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   711
    "
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   712
!
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   713
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   714
addSeconds:numberOfSeconds
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   715
    "return a new instance of myself, numberOfSeconds afterwards."
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   716
17015
f7c4867a3633 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16982
diff changeset
   717
    ^ self speciesNew 
3476
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   718
        setMilliseconds:(self getMilliseconds + (numberOfSeconds * 1000))
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   719
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   720
    "
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   721
     |t|
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   722
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   723
     t := Timestamp now.
3476
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   724
     Transcript showCR:t.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   725
     Transcript showCR:(t addSeconds:60).
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   726
    "
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   727
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   728
    "
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   729
     |t|
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   730
3476
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   731
     t := Time now.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   732
     Transcript showCR:t.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   733
     Transcript showCR:(t addSeconds:60).
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   734
    "
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   735
!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   736
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   737
addTime:timeAmount
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   738
    "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
   739
     Provided for ST-80 compatibility.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   740
     WARNING:
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   741
        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
   742
        a numberOfSeconds as argument. 
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   743
        Use any of addSeconds/addHours etc. to make things clear"
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   744
6888
d75cbe2e8ef7 addTime / subtractTime handle non-Number argument
Claus Gittinger <cg@exept.de>
parents: 6795
diff changeset
   745
    timeAmount isNumber ifFalse:[
d75cbe2e8ef7 addTime / subtractTime handle non-Number argument
Claus Gittinger <cg@exept.de>
parents: 6795
diff changeset
   746
        ^ self addSeconds:(timeAmount asSeconds).
d75cbe2e8ef7 addTime / subtractTime handle non-Number argument
Claus Gittinger <cg@exept.de>
parents: 6795
diff changeset
   747
    ].
3476
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   748
    ^ self addSeconds:timeAmount
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   749
!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   750
16475
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
   751
deltaFrom:aTimeOrInteger
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
   752
    "return the delta as a timeDuration between 2 timeStamps.
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
   753
     The argument is supposed to be BEFORE the receiver,
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
   754
        computes self - aTimestamp"
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
   755
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
   756
    ^ aTimeOrInteger differenceFromTimestamp:self
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
   757
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
   758
    "
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
   759
        Time now deltaFrom:10 minutes.
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
   760
        Time now deltaFrom:3600.
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
   761
        Time now deltaFrom:3600 seconds.
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
   762
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
   763
        Timestamp now deltaFrom:10 minutes.
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
   764
        Timestamp now deltaFrom:3600.
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
   765
        Timestamp now deltaFrom:3600 seconds.
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
   766
    "
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
   767
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
   768
    "
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
   769
     |t1 t2|
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
   770
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
   771
     t1 := Timestamp now.
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
   772
     Delay waitForSeconds:0.5.
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
   773
     t2 := Timestamp now.
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
   774
     t2 deltaFrom:t1   
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
   775
    "
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
   776
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
   777
    "Created: / 04-10-2007 / 13:34:28 / cg"
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
   778
    "Modified: / 10-07-2010 / 09:37:01 / cg"
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
   779
!
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
   780
16505
c285d94f2248 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16475
diff changeset
   781
roundTo:aTimeDuration
c285d94f2248 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16475
diff changeset
   782
     ^ self class new setMilliseconds:(self getMilliseconds roundTo:aTimeDuration getMilliseconds)
c285d94f2248 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16475
diff changeset
   783
c285d94f2248 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16475
diff changeset
   784
    "
c285d94f2248 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16475
diff changeset
   785
      (TimeDuration fromMilliseconds:25234) roundTo:2 seconds
c285d94f2248 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16475
diff changeset
   786
      Time now roundTo:10 minutes
c285d94f2248 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16475
diff changeset
   787
      Timestamp now roundTo:10 minutes
c285d94f2248 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16475
diff changeset
   788
    "
c285d94f2248 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16475
diff changeset
   789
!
c285d94f2248 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16475
diff changeset
   790
6048
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   791
subtractDays:numberOfDays
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   792
    "return a new instance of myself, numberOfDays before."
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   793
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   794
    ^ self subtractSeconds:(numberOfDays * (60 * 60 * 24))
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   795
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   796
    "
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   797
     |t|
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   798
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   799
     t := Timestamp now.
6048
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   800
     Transcript showCR:t.
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   801
     Transcript showCR:(t subtractDays:50)
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   802
    "
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   803
!
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   804
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   805
subtractHours:numberOfHours
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   806
    "return a new instance of myself, numberOfHours before."
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   807
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   808
    ^ self subtractSeconds:(numberOfHours * (60 * 60))
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   809
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   810
    "
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   811
     |t|
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   812
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   813
     t := Timestamp now.
3476
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   814
     Transcript showCR:t.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   815
     Transcript showCR:(t subtractHours:12).
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   816
    "
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   817
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   818
    "
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   819
     |t|
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   820
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   821
     t := Time now.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   822
     Transcript showCR:t.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   823
     Transcript showCR:(t subtractHours:12).
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   824
    "
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   825
!
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   826
6043
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   827
subtractMilliseconds:numberOfMilliSeconds
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   828
    "return a new instance of myself, numberOfMilliSeconds before."
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   829
17015
f7c4867a3633 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16982
diff changeset
   830
    ^ self speciesNew 
6043
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   831
        setMilliseconds:(self getMilliseconds - numberOfMilliSeconds)
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   832
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   833
    "
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   834
     |t|
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   835
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   836
     t := Timestamp now.
6043
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   837
     Transcript showCR:t.
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   838
     Transcript showCR:(t subtractMilliseconds:100).
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   839
    "
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   840
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   841
    "
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   842
     |t|
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   843
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   844
     t := Time now.
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   845
     Transcript showCR:t.
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   846
     Transcript showCR:(t subtractMilliseconds:1000).
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   847
    "
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   848
!
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   849
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   850
subtractMinutes:numberOfMinutes
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   851
    "return a new instance of myself, numberOfMinutes before."
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   852
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   853
    ^ self subtractSeconds:(numberOfMinutes * 60)
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   854
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   855
    "
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   856
     |t|
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   857
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   858
     t := Timestamp now.
3476
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   859
     Transcript showCR:t.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   860
     Transcript showCR:(t subtractMinutes:60).
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   861
    "
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   862
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   863
    "
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   864
     |t|
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   865
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   866
     t := Time now.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   867
     Transcript showCR:t.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   868
     Transcript showCR:(t subtractMinutes:60).
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   869
    "
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   870
!
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   871
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   872
subtractSeconds:numberOfSeconds
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   873
    "return a new instance of myself, numberOfSeconds before."
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   874
17015
f7c4867a3633 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16982
diff changeset
   875
    ^ self speciesNew 
3476
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   876
        setMilliseconds:(self getMilliseconds - (numberOfSeconds * 1000))
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   877
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   878
    "
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   879
     |t|
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   880
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   881
     t := Timestamp now.
3476
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   882
     Transcript showCR:t.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   883
     Transcript showCR:(t subtractSeconds:60).
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   884
    "
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   885
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   886
    "
3476
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   887
     |t|
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   888
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   889
     t := Time now.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   890
     Transcript showCR:t.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   891
     Transcript showCR:(t subtractSeconds:60).
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   892
    "
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   893
!
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   894
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   895
subtractTime:timeAmount
3476
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   896
    "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
   897
     Provided for ST-80 compatibility.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   898
     WARNING:
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   899
        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
   900
        a numberOfSeconds as argument. 
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   901
        Use any of addSeconds/addHours etc. to make things clear"
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   902
6888
d75cbe2e8ef7 addTime / subtractTime handle non-Number argument
Claus Gittinger <cg@exept.de>
parents: 6795
diff changeset
   903
    timeAmount isNumber ifFalse:[
d75cbe2e8ef7 addTime / subtractTime handle non-Number argument
Claus Gittinger <cg@exept.de>
parents: 6795
diff changeset
   904
        ^ self subtractSeconds:(timeAmount asSeconds).
d75cbe2e8ef7 addTime / subtractTime handle non-Number argument
Claus Gittinger <cg@exept.de>
parents: 6795
diff changeset
   905
    ].
3476
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   906
    ^ self subtractSeconds:timeAmount
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   907
16505
c285d94f2248 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16475
diff changeset
   908
!
c285d94f2248 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16475
diff changeset
   909
c285d94f2248 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16475
diff changeset
   910
truncateTo:aTimeDuration
c285d94f2248 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16475
diff changeset
   911
     ^ self class new setMilliseconds:(self getMilliseconds truncateTo:aTimeDuration getMilliseconds)
c285d94f2248 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16475
diff changeset
   912
c285d94f2248 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16475
diff changeset
   913
    "
c285d94f2248 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16475
diff changeset
   914
      (TimeDuration fromMilliseconds:25234) truncateTo:2 seconds
c285d94f2248 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16475
diff changeset
   915
      Time now truncateTo:10 minutes
c285d94f2248 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16475
diff changeset
   916
      Timestamp now truncateTo:10 minutes
c285d94f2248 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16475
diff changeset
   917
    "
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   918
! !
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   919
5573
efd0dc6578ac #-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 5548
diff changeset
   920
!AbstractTime methodsFor:'comparing'!
efd0dc6578ac #-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 5548
diff changeset
   921
efd0dc6578ac #-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 5548
diff changeset
   922
< aTime
efd0dc6578ac #-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 5548
diff changeset
   923
    "return true if the receiver is before the argument"
efd0dc6578ac #-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 5548
diff changeset
   924
efd0dc6578ac #-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 5548
diff changeset
   925
    ^ self getMilliseconds < aTime getMilliseconds
efd0dc6578ac #-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 5548
diff changeset
   926
efd0dc6578ac #-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 5548
diff changeset
   927
    "Modified: 3.7.1996 / 13:10:17 / cg"
efd0dc6578ac #-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 5548
diff changeset
   928
!
efd0dc6578ac #-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 5548
diff changeset
   929
efd0dc6578ac #-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 5548
diff changeset
   930
> aTime
efd0dc6578ac #-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 5548
diff changeset
   931
    "return true if the receiver is after the argument"
efd0dc6578ac #-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 5548
diff changeset
   932
efd0dc6578ac #-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 5548
diff changeset
   933
    ^ self getMilliseconds > aTime getMilliseconds
efd0dc6578ac #-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 5548
diff changeset
   934
efd0dc6578ac #-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 5548
diff changeset
   935
    "Modified: 1.7.1996 / 15:24:38 / cg"
efd0dc6578ac #-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 5548
diff changeset
   936
! !
efd0dc6578ac #-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 5548
diff changeset
   937
8200
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   938
!AbstractTime methodsFor:'converting'!
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   939
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   940
asAbsoluteTime
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   941
    "deprecated, use #asTimestamp"
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   942
    <resource:#obsolete>
8200
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   943
12002
3ecffb2d77ad *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11772
diff changeset
   944
    self obsoleteMethodWarning:'use #asTimestamp'.
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   945
    ^ self asTimestamp
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   946
!
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   947
13233
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
   948
asLocalTimestamp
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
   949
    "represent myself as a timestamp in the local timezone"
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
   950
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
   951
    ^ self subclassResponsibility
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
   952
!
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
   953
17140
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
   954
asMilliseconds
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
   955
    "return the number of milliseconds elapsed since midnight"
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
   956
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
   957
    ^ self getMilliseconds
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
   958
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
   959
    "
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
   960
     Time now asMilliseconds
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
   961
     Timestamp now asMilliseconds
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
   962
     (TimeDuration days:1) asMilliseconds
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
   963
     (TimeDuration hours:1) asMilliseconds
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
   964
    "
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
   965
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
   966
    "Created: / 05-09-2011 / 10:40:15 / cg"
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
   967
!
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
   968
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
   969
asSeconds
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
   970
    "return the number of seconds elapsed since midnight"
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
   971
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
   972
    ^ self getSeconds
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
   973
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
   974
    "
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
   975
     Timestamp now asSeconds
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
   976
     Time now asSeconds
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
   977
     (TimeDuration days:1) asSeconds
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
   978
    "
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
   979
!
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
   980
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   981
asTimestamp
13233
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
   982
    "represent myself as a Timestamp"
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
   983
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
   984
    ^ self subclassResponsibility
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
   985
!
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
   986
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
   987
asUtcTimestamp
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
   988
    "represent myself as a timestamp in the local timezone"
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
   989
8200
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   990
    ^ self subclassResponsibility
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   991
! !
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   992
11518
8b4cafbd318a double dispatch for time-difference
sr
parents: 11515
diff changeset
   993
!AbstractTime methodsFor:'double dispatching'!
8b4cafbd318a double dispatch for time-difference
sr
parents: 11515
diff changeset
   994
8b4cafbd318a double dispatch for time-difference
sr
parents: 11515
diff changeset
   995
differenceFromTimestamp:aTimestamp
16365
7255d544da96 class: TimeDuration
Claus Gittinger <cg@exept.de>
parents: 15684
diff changeset
   996
    "/ the correct thing to do (and I will, in the future) is to
7255d544da96 class: TimeDuration
Claus Gittinger <cg@exept.de>
parents: 15684
diff changeset
   997
    "/ return a TimeDuration:
7255d544da96 class: TimeDuration
Claus Gittinger <cg@exept.de>
parents: 15684
diff changeset
   998
    "/
16934
2a4639715b07 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16926
diff changeset
   999
    ^ TimeDuration fromMilliseconds:(aTimestamp getMilliseconds - self getMilliseconds).
16407
67eeb7ae5eb8 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16365
diff changeset
  1000
16365
7255d544da96 class: TimeDuration
Claus Gittinger <cg@exept.de>
parents: 15684
diff changeset
  1001
    "/ which is the same as: deltaFrom:aTimestamp
7255d544da96 class: TimeDuration
Claus Gittinger <cg@exept.de>
parents: 15684
diff changeset
  1002
    "/
7255d544da96 class: TimeDuration
Claus Gittinger <cg@exept.de>
parents: 15684
diff changeset
  1003
    "/ however, there might be old code around, which is not be prepared for
7255d544da96 class: TimeDuration
Claus Gittinger <cg@exept.de>
parents: 15684
diff changeset
  1004
    "/ getting a non-number (the seconds). Therefore, for the meantime,
7255d544da96 class: TimeDuration
Claus Gittinger <cg@exept.de>
parents: 15684
diff changeset
  1005
    "/ we return:
7255d544da96 class: TimeDuration
Claus Gittinger <cg@exept.de>
parents: 15684
diff changeset
  1006
7255d544da96 class: TimeDuration
Claus Gittinger <cg@exept.de>
parents: 15684
diff changeset
  1007
    "/ ^ aTimestamp getSeconds - self getSeconds
11518
8b4cafbd318a double dispatch for time-difference
sr
parents: 11515
diff changeset
  1008
! !
8b4cafbd318a double dispatch for time-difference
sr
parents: 11515
diff changeset
  1009
4649
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1010
!AbstractTime methodsFor:'printing & storing'!
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1011
16829
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1012
addBasicPrintBindingsTo:aDictionary language:languageOrNil
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1013
    "private print support: add bindings for printing to aDictionary.
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1014
     languageOrNil can be #en, #fr, #de or nil for the current language.
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1015
     Here only basic bindings are added - no timezone am am/pm stuff,
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1016
     which doesn't make sense for TimeDuration.
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1017
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1018
     bindings:
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1019
        %h      hours, 00..23 (i.e. european)  0-padded to length 2
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1020
        %m      minutes, 00..59                0-padded to length 2
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1021
        %s      seconds, 00..59                0-padded to length 2
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1022
        %i      milliseconds, 000..999         0-padded to length 3
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1023
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1024
     Timestamp only:
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1025
        %(day)   day, 00..31                    0-padded to length 2
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1026
        %(month) month, 00..12                  0-padded to length 2
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1027
        %(year)  year, 4 digits                 0-padded to length 4
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1028
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1029
     special:
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1030
        %H      24-hours - unpadded
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1031
        %M      minutes - unpadded
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1032
        %S      seconds - unpadded
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1033
        %I      milliseconds, unpadded
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1034
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1035
        %t      seconds within hour  (unpadded)
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1036
        %T      seconds from midNight  (unpadded)
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1037
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1038
        %(milli1) milliseconds, truncated to 1/10th of a second 0..9         
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1039
        %(milli2) milliseconds, truncated to 1/100th of a second 00..99 0-padded to length 2        
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1040
        %(milli3) milliseconds, same as %i for convenience
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1041
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1042
     Timestamp only:
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1043
        %(Day)         - day - unpadded                    
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1044
        %(Month)       - month - unpadded                    
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1045
        %(yearOrTime)  - year or time 5 digits    as in unix-ls:
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1046
                                                  year if it is not the current year;
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1047
                                                  time otherwise
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1048
        %(weekDay)      - day in week (1->monday, 2->tuesday, ... ,7->sunday)
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1049
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1050
        %(dayName)      - full day name     
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1051
        %(DayName)      - full day name, first character uppercase      
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1052
        %(DAYNAME)      - full day name, all uppercase       
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1053
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1054
        %(monthName)    - full month name     
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1055
        %(MonthName)    - full month name, first character uppercase      
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1056
        %(MONTHNAME)    - full month name, all uppercase       
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1057
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1058
        %(shortDayName) - short (abbreviated) day name     
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1059
        %(ShortDayName) - short (abbreviated) day name, first character uppercase      
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1060
        %(SHORTDAYNAME) - short (abbreviated) day name, all uppercase       
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1061
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1062
        %(shortMonthName) - short (abbreviated) month name     
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1063
        %(ShortMonthName) - short (abbreviated) month name, first character uppercase      
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1064
        %(SHORTMONTHNAME) - short (abbreviated) month name, all uppercase       
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1065
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1066
        %(nth)          - counting day-in-month (1->'st'; 2->'nd'; 3->'rd'; 4...->'th')      
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1067
        %(weekDayNth)   - counting day-in-week (1->'st'; 2->'nd'; 3->'rd'; 4...->'th')      
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1068
        %(weekNth)      - counting week-in-year (1->'st'; 2->'nd'; 3->'rd'; 4...->'th')
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1069
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1070
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1071
     The ISO8601 printString are generated with:
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1072
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1073
       Year:
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1074
          YYYY (eg 1997)
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1075
                Date today printStringFormat:'%(year)'
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1076
                Timestamp now printStringFormat:'%(year)'  
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1077
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1078
       Year and month:
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1079
          YYYY-MM (eg 1997-07)
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1080
                Date today printStringFormat:'%(year)-%(month)'  
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1081
                Timestamp now printStringFormat:'%(year)-%(month)'  
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1082
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1083
       Complete date:
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1084
          YYYY-MM-DD (eg 1997-07-16)
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1085
                Date today printStringFormat:'%(year)-%(month)-%(day)'    
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1086
                Timestamp now printStringFormat:'%(year)-%(month)-%(day)'  
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1087
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1088
       Complete date plus hours and minutes:
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1089
          YYYY-MM-DDThh:mmTZD (eg 1997-07-16T19:20+01:00)
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1090
                Timestamp now printStringFormat:'%(year)-%(month)-%(day)T%h:%m%(TZD)'  
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1091
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1092
       Complete date plus hours, minutes and seconds:
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1093
          YYYY-MM-DDThh:mm:ssTZD (eg 1997-07-16T19:20:30+01:00)
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1094
                Timestamp now printStringFormat:'%(year)-%(month)-%(day)T%h:%m:%s%(TZD)'  
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1095
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1096
       Complete date plus hours, minutes, seconds and a decimal fraction of a second
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1097
          YYYY-MM-DDThh:mm:ss.sTZD (eg 1997-07-16T19:20:30.45+01:00)
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1098
                Timestamp now printStringFormat:'%(year)-%(month)-%(day)T%h:%m:%s.%(milli2)%(TZD)'  
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1099
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1100
    "
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1101
16926
755f4c452bf4 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16829
diff changeset
  1102
    |time hours minutes seconds millis s t|
16829
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1103
16926
755f4c452bf4 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16829
diff changeset
  1104
    time := self asTime.
755f4c452bf4 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16829
diff changeset
  1105
    hours := time hours.
755f4c452bf4 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16829
diff changeset
  1106
    minutes := time minutes.
755f4c452bf4 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16829
diff changeset
  1107
    seconds := time seconds.
16829
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1108
    millis := self milliseconds.
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1109
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1110
    aDictionary at:$H put:(s := hours printString).
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1111
    aDictionary at:$h put:(s leftPaddedTo:2 with:$0).
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1112
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1113
    aDictionary at:$M put:(s := minutes printString).
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1114
    aDictionary at:$m put:(s leftPaddedTo:2 with:$0).
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1115
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1116
    aDictionary at:$S put:(s := seconds printString).
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1117
    aDictionary at:$s put:(s leftPaddedTo:2 with:$0).
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1118
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1119
    aDictionary at:$I put:(s := millis printString).
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1120
    aDictionary at:$i put:(t := s leftPaddedTo:3 with:$0).
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1121
    aDictionary at:#milli3 put:t.
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1122
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1123
    aDictionary at:#milli1 put:((millis // 100) printString).
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1124
    aDictionary at:#milli2 put:((millis // 10) printStringLeftPaddedTo:2 with:$0).
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1125
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1126
    aDictionary at:$t put:(seconds * minutes) printString.
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1127
    aDictionary at:$T put:(seconds * minutes * hours) printString.
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1128
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1129
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1130
    "
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1131
      |dict|
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1132
      dict := Dictionary new.
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1133
      Timestamp now addBasicPrintBindingsTo:dict language:#en.
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1134
      dict inspect
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1135
    "
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1136
!
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1137
4844
6938f0df31f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4841
diff changeset
  1138
addPrintBindingsTo:aDictionary
16829
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1139
    <resource: #obsolete>
8111
67347b7e3e69 print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents: 7672
diff changeset
  1140
16829
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1141
    self obsoleteMethodWarning:'use #addPrintBindingsTo:language:'.
8111
67347b7e3e69 print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents: 7672
diff changeset
  1142
    self addPrintBindingsTo:aDictionary language:nil
67347b7e3e69 print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents: 7672
diff changeset
  1143
!
67347b7e3e69 print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents: 7672
diff changeset
  1144
67347b7e3e69 print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents: 7672
diff changeset
  1145
addPrintBindingsTo:aDictionary language:languageOrNil
67347b7e3e69 print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents: 7672
diff changeset
  1146
    "private print support: add bindings for printing to aDictionary.
13175
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1147
     languageOrNil can be #en, #fr, #de or nil for the current language.
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1148
11772
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1149
     bindings:
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1150
        %h      hours, 00..23 (i.e. european)  0-padded to length 2
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1151
        %u      hours, 00..12 (i.e. us)        0-padded to length 2
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1152
        %m      minutes, 00..59                0-padded to length 2
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1153
        %s      seconds, 00..59                0-padded to length 2
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1154
        %i      milliseconds, 000..999         0-padded to length 3
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1155
        %a      am/pm
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1156
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1157
     Timestamp only:
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1158
        %(day)   day, 00..31                    0-padded to length 2
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1159
        %(month) month, 00..12                  0-padded to length 2
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1160
        %(year)  year, 4 digits                 0-padded to length 4
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1161
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1162
     special:
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1163
        %H      24-hours - unpadded
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1164
        %U      12-hours - unpadded
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1165
        %M      minutes - unpadded
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1166
        %S      seconds - unpadded
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1167
        %I      milliseconds, unpadded
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1168
        %A      AM/PM   - uppercase
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1169
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1170
        %t      seconds within hour  (unpadded)
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1171
        %T      seconds from midNight  (unpadded)
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1172
16982
c37260d6ff78 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16941
diff changeset
  1173
        %(TZD)  timeZone delta of the receiver from UTC in the format +/-hh:mm  
11772
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1174
13175
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1175
        %(milli1) milliseconds, truncated to 1/10th of a second 0..9         
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1176
        %(milli2) milliseconds, truncated to 1/100th of a second 00..99 0-padded to length 2        
14493
0a3c9081d40a changed: #addPrintBindingsTo:language:
Claus Gittinger <cg@exept.de>
parents: 13701
diff changeset
  1177
        %(milli3) milliseconds, same as %i for convenience
11772
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1178
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1179
     Timestamp only:
13175
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1180
        %(Day)         - day - unpadded                    
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1181
        %(Month)       - month - unpadded                    
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1182
        %(yearOrTime)  - year or time 5 digits    as in unix-ls:
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1183
                                                  year if it is not the current year;
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1184
                                                  time otherwise
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1185
        %(weekDay)      - day in week (1->monday, 2->tuesday, ... ,7->sunday)
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1186
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1187
        %(dayName)      - full day name     
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1188
        %(DayName)      - full day name, first character uppercase      
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1189
        %(DAYNAME)      - full day name, all uppercase       
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1190
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1191
        %(monthName)    - full month name     
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1192
        %(MonthName)    - full month name, first character uppercase      
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1193
        %(MONTHNAME)    - full month name, all uppercase       
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1194
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1195
        %(shortDayName) - short (abbreviated) day name     
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1196
        %(ShortDayName) - short (abbreviated) day name, first character uppercase      
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1197
        %(SHORTDAYNAME) - short (abbreviated) day name, all uppercase       
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1198
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1199
        %(shortMonthName) - short (abbreviated) month name     
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1200
        %(ShortMonthName) - short (abbreviated) month name, first character uppercase      
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1201
        %(SHORTMONTHNAME) - short (abbreviated) month name, all uppercase       
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1202
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1203
        %(nth)          - counting day-in-month (1->'st'; 2->'nd'; 3->'rd'; 4...->'th')      
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1204
        %(weekDayNth)   - counting day-in-week (1->'st'; 2->'nd'; 3->'rd'; 4...->'th')      
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1205
        %(weekNth)      - counting week-in-year (1->'st'; 2->'nd'; 3->'rd'; 4...->'th')
11772
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1206
17195
8c13747ba36d class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 17140
diff changeset
  1207
        %(yearRoman)    - year, in roman letters                    
8c13747ba36d class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 17140
diff changeset
  1208
        %(monthRoman)   - month, in roman letters                    
8c13747ba36d class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 17140
diff changeset
  1209
11772
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1210
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1211
     The ISO8601 printString are generated with:
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1212
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1213
       Year:
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1214
          YYYY (eg 1997)
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1215
                Date today printStringFormat:'%(year)'
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1216
                Timestamp now printStringFormat:'%(year)'  
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1217
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1218
       Year and month:
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1219
          YYYY-MM (eg 1997-07)
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1220
                Date today printStringFormat:'%(year)-%(month)'  
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1221
                Timestamp now printStringFormat:'%(year)-%(month)'  
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1222
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1223
       Complete date:
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1224
          YYYY-MM-DD (eg 1997-07-16)
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1225
                Date today printStringFormat:'%(year)-%(month)-%(day)'    
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1226
                Timestamp now printStringFormat:'%(year)-%(month)-%(day)'  
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1227
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1228
       Complete date plus hours and minutes:
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1229
          YYYY-MM-DDThh:mmTZD (eg 1997-07-16T19:20+01:00)
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1230
                Timestamp now printStringFormat:'%(year)-%(month)-%(day)T%h:%m%(TZD)'  
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1231
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1232
       Complete date plus hours, minutes and seconds:
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1233
          YYYY-MM-DDThh:mm:ssTZD (eg 1997-07-16T19:20:30+01:00)
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1234
                Timestamp now printStringFormat:'%(year)-%(month)-%(day)T%h:%m:%s%(TZD)'  
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1235
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1236
       Complete date plus hours, minutes, seconds and a decimal fraction of a second
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1237
          YYYY-MM-DDThh:mm:ss.sTZD (eg 1997-07-16T19:20:30.45+01:00)
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1238
                Timestamp now printStringFormat:'%(year)-%(month)-%(day)T%h:%m:%s.%(milli2)%(TZD)'  
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1239
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1240
    "
4844
6938f0df31f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4841
diff changeset
  1241
16829
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1242
    |usHours ampm s zone tzDelta|
4844
6938f0df31f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4841
diff changeset
  1243
16829
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1244
    self addBasicPrintBindingsTo:aDictionary language:languageOrNil.
5968
4832ed93f0b4 preps for timeZone
Claus Gittinger <cg@exept.de>
parents: 5964
diff changeset
  1245
    zone := self timeZoneName.
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
  1246
    tzDelta := self timeZoneDeltaInMinutes.
4844
6938f0df31f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4841
diff changeset
  1247
6419
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
  1248
    ampm := self meridianAbbreviation.
16829
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1249
    usHours := self hour12 printString.
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1250
    aDictionary at:$U put:usHours.
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1251
    aDictionary at:$u put:(usHours leftPaddedTo:2 with:$0).
14493
0a3c9081d40a changed: #addPrintBindingsTo:language:
Claus Gittinger <cg@exept.de>
parents: 13701
diff changeset
  1252
0a3c9081d40a changed: #addPrintBindingsTo:language:
Claus Gittinger <cg@exept.de>
parents: 13701
diff changeset
  1253
12662
a19b835e49a0 changed: #addPrintBindingsTo:language:
sr
parents: 12660
diff changeset
  1254
    aDictionary at:$a put:ampm.
a19b835e49a0 changed: #addPrintBindingsTo:language:
sr
parents: 12660
diff changeset
  1255
    aDictionary at:$A put:ampm asUppercase.
a19b835e49a0 changed: #addPrintBindingsTo:language:
sr
parents: 12660
diff changeset
  1256
    aDictionary at:$z put:zone.
a19b835e49a0 changed: #addPrintBindingsTo:language:
sr
parents: 12660
diff changeset
  1257
    aDictionary at:$Z put:zone asUppercase.
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
  1258
9432
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
  1259
    tzDelta == 0 ifTrue:[
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
  1260
        s := 'Z'.
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
  1261
    ] ifFalse:[
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
  1262
        s := tzDelta < 0 ifTrue:[ '-' ] ifFalse:[ '+' ].
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
  1263
        tzDelta := tzDelta abs.
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
  1264
        s := s  , ((tzDelta // 60) printStringLeftPaddedTo:2 with:$0), 
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
  1265
            ':' , ((tzDelta \\ 60) printStringLeftPaddedTo:2 with:$0).
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
  1266
    ].
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
  1267
    aDictionary at:#TZD put:s
13082
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1268
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1269
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1270
    "
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1271
      |dict|
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1272
      dict := Dictionary new.
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1273
      Timestamp now addPrintBindingsTo:dict language:#en.
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1274
      dict inspect
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1275
    "
4844
6938f0df31f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4841
diff changeset
  1276
!
6938f0df31f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4841
diff changeset
  1277
4649
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1278
printOn:aStream format:aFormatString
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1279
    "print using a format string;
13175
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1280
     See #addPrintBindingsTo:language: for allowed format strings"
7327
ab17eb5f11a6 printFormat
Claus Gittinger <cg@exept.de>
parents: 7294
diff changeset
  1281
13175
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1282
    self printOn:aStream format:aFormatString language:nil.
10907
8b98ba82a46f Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents: 10770
diff changeset
  1283
8b98ba82a46f Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents: 10770
diff changeset
  1284
    "
8b98ba82a46f Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents: 10770
diff changeset
  1285
     Timestamp now printOn:Transcript format:'%h:%m:%s'   . Transcript cr.      
8b98ba82a46f Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents: 10770
diff changeset
  1286
     Time now printOn:Transcript format:'%h:%m:%s'   . Transcript cr.      
8b98ba82a46f Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents: 10770
diff changeset
  1287
     Time now printOn:Transcript format:'%H:%m:%s'   . Transcript cr.      
8b98ba82a46f Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents: 10770
diff changeset
  1288
     Time now printOn:Transcript format:'%u:%m:%s %a'. Transcript cr.   
8b98ba82a46f Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents: 10770
diff changeset
  1289
     Time now printOn:Transcript format:'%h:%m'      . Transcript cr. 
8b98ba82a46f Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents: 10770
diff changeset
  1290
     Time now printOn:Transcript format:'%H:%m %A'   . Transcript cr.
8b98ba82a46f Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents: 10770
diff changeset
  1291
     Time now printOn:Transcript format:'minutes:%M seconds:%S'. Transcript cr.
8b98ba82a46f Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents: 10770
diff changeset
  1292
    "
8b98ba82a46f Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents: 10770
diff changeset
  1293
8b98ba82a46f Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents: 10770
diff changeset
  1294
    "Modified: 22.2.1996 / 16:58:30 / cg"
8b98ba82a46f Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents: 10770
diff changeset
  1295
!
8b98ba82a46f Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents: 10770
diff changeset
  1296
13082
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1297
printOn:aStream format:aFormatString language:languageString
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1298
    "print using a format string;
13175
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1299
     See #addPrintBindingsTo:language: for allowed format strings"
13082
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1300
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1301
    |dict|
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1302
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1303
    dict := IdentityDictionary new.
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1304
    self addPrintBindingsTo:dict language:languageString.
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1305
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1306
    aFormatString expandPlaceholdersWith:dict on:aStream
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1307
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1308
    "
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1309
     Timestamp now printOn:Transcript format:'%h:%m:%s'   . Transcript cr.      
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1310
     Time now printOn:Transcript format:'%h:%m:%s'   . Transcript cr.      
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1311
     Time now printOn:Transcript format:'%H:%m:%s'   . Transcript cr.      
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1312
     Time now printOn:Transcript format:'%u:%m:%s %a'. Transcript cr.   
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1313
     Time now printOn:Transcript format:'%h:%m'      . Transcript cr. 
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1314
     Time now printOn:Transcript format:'%H:%m %A'   . Transcript cr.
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1315
     Time now printOn:Transcript format:'minutes:%M seconds:%S'. Transcript cr.
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1316
    "
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1317
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1318
    "Modified: 22.2.1996 / 16:58:30 / cg"
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1319
!
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1320
10907
8b98ba82a46f Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents: 10770
diff changeset
  1321
printStringFormat:aFormatString
13175
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1322
    "print using a format string.
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1323
     See #addPrintBindingsTo:language: for allowed format strings"
10907
8b98ba82a46f Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents: 10770
diff changeset
  1324
13175
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1325
    ^ self printStringFormat:aFormatString language:nil.
4649
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1326
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1327
    "
17400
2aad82c1d66c class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 17195
diff changeset
  1328
     Timestamp now printStringFormat:'%U:%m:%s %a'        
2aad82c1d66c class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 17195
diff changeset
  1329
     Timestamp now printStringFormat:'%u:%m:%s %a'        
4649
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1330
     Time now printStringFormat:'%U:%m:%s %a'   
17400
2aad82c1d66c class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 17195
diff changeset
  1331
     Time now printStringFormat:'%u:%m:%s %a'   
4649
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1332
4844
6938f0df31f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4841
diff changeset
  1333
     Time now printStringFormat:'%h:%m:%s'      
4649
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1334
     Time now printStringFormat:'%H:%m:%s'      
4844
6938f0df31f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4841
diff changeset
  1335
     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
  1336
     Timestamp now printStringFormat:'%H:%m:%s.%i'   
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
  1337
     Timestamp now printStringFormat:'%H:%m:%s.%(milli1)'   
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
  1338
     Timestamp now printStringFormat:'%H:%m:%s.%(milli2)'     
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
  1339
     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
  1340
     Timestamp now printStringFormat:'%(day)-%(monthName)-%(year) :%m:%s'       
4649
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1341
     Time now printStringFormat:'%u:%m:%s %a'   
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1342
     Time now printStringFormat:'%h:%m'         
4844
6938f0df31f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4841
diff changeset
  1343
     Time now printStringFormat:'%h:%m'         
4649
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1344
     Time now printStringFormat:'%H:%m %A'     
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1345
     Time now printStringFormat:'%m minutes after %U %a'     
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1346
     Time now printStringFormat:'%t seconds after %U %a'     
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1347
     Time now printStringFormat:'%T seconds from midNight'     
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1348
    "
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1349
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1350
    "Modified: 22.2.1996 / 16:58:30 / cg"
13082
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1351
!
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1352
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1353
printStringFormat:aFormatString language:languageString
13175
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1354
    "print using a format string.
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1355
     See #addPrintBindingsTo:language: for allowed format strings"
13082
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1356
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1357
    |s|
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1358
16829
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1359
    s := CharacterWriteStream on:(String new:20).
13082
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1360
    self printOn:s format:aFormatString language:languageString.
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1361
    ^ s contents.
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1362
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1363
    "
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1364
     Timestamp now printStringFormat:'%U:%m:%s %a  
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1365
     Time now printStringFormat:'%U:%m:%s %a'   
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1366
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1367
     Time now printStringFormat:'%h:%m:%s'      
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1368
     Time now printStringFormat:'%H:%m:%s'      
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1369
     Time now printStringFormat:'%H:%m:%s.%i'           
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1370
     Timestamp now printStringFormat:'%H:%m:%s.%i'   
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1371
     Timestamp now printStringFormat:'%H:%m:%s.%(milli1)'   
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1372
     Timestamp now printStringFormat:'%H:%m:%s.%(milli2)'     
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1373
     Timestamp now printStringFormat:'%(day)-%(month)-%(year) :%m:%s'       
13175
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1374
     Timestamp now printStringFormat:'%(day)-%(monthName)-%(year) :%m:%s' language:#en      
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1375
     Timestamp now printStringFormat:'%(day)-%(monthName)-%(year) :%m:%s' language:#de      
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1376
     Timestamp now printStringFormat:'%(day)-%(monthName)-%(year) :%m:%s' language:#fr      
13082
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1377
     Time now printStringFormat:'%u:%m:%s %a'   
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1378
     Time now printStringFormat:'%h:%m'         
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1379
     Time now printStringFormat:'%h:%m'         
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1380
     Time now printStringFormat:'%H:%m %A'     
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1381
     Time now printStringFormat:'%m minutes after %U %a'     
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1382
     Time now printStringFormat:'%t seconds after %U %a'     
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1383
     Time now printStringFormat:'%T seconds from midNight'     
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1384
    "
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1385
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1386
    "Modified: 22.2.1996 / 16:58:30 / cg"
4649
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1387
! !
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1388
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1389
!AbstractTime methodsFor:'private'!
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
  1390
1500
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1391
fromOSTime:osTime
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1392
    "set my time, from operatingSystems time parts"
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
  1393
1500
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1394
    ^ self subclassResponsibility
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1395
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1396
    "Modified: 1.7.1996 / 15:09:44 / cg"
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
  1397
!
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
  1398
1500
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1399
getMilliseconds
8200
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
  1400
    "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
  1401
     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
  1402
     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
  1403
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1404
    ^ self subclassResponsibility
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1405
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1406
    "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
  1407
!
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1408
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1409
getSeconds
8200
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
  1410
    "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
  1411
     Since I am abstract (not knowing how the time is actually
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1412
     represented), this must be done by a concrete class."
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
  1413
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1414
    ^ self subclassResponsibility
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1415
!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1416
1500
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1417
setMilliseconds:millis
8200
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
  1418
    "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
  1419
     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
  1420
     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
  1421
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1422
    ^ self subclassResponsibility
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1423
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1424
    "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
  1425
!
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1426
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1427
setSeconds:secs
8200
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
  1428
    "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
  1429
     Since I am abstract (not knowing how the time is actually
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1430
     represented), this must be done by a concrete class."
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1431
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1432
    ^ self subclassResponsibility
17015
f7c4867a3633 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16982
diff changeset
  1433
!
f7c4867a3633 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16982
diff changeset
  1434
f7c4867a3633 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16982
diff changeset
  1435
speciesNew
f7c4867a3633 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16982
diff changeset
  1436
    ^ self species basicNew
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
  1437
! !
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
  1438
2310
2cb1366e0eb3 Correct name: #secondDay --> #secondInDay.
Stefan Vogel <sv@exept.de>
parents: 1500
diff changeset
  1439
!AbstractTime class methodsFor:'documentation'!
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
  1440
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1441
version
17400
2aad82c1d66c class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 17195
diff changeset
  1442
    ^ '$Header: /cvs/stx/stx/libbasic/AbstractTime.st,v 1.91 2015-02-03 19:01:47 cg Exp $'
12660
518ee2523071 changed: #addPrintBindingsTo:language:
sr
parents: 12002
diff changeset
  1443
!
518ee2523071 changed: #addPrintBindingsTo:language:
sr
parents: 12002
diff changeset
  1444
518ee2523071 changed: #addPrintBindingsTo:language:
sr
parents: 12002
diff changeset
  1445
version_CVS
17400
2aad82c1d66c class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 17195
diff changeset
  1446
    ^ '$Header: /cvs/stx/stx/libbasic/AbstractTime.st,v 1.91 2015-02-03 19:01:47 cg Exp $'
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
  1447
! !
15684
4c4bc53e32c8 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 14494
diff changeset
  1448