AbstractTime.st
author mawalch
Mon, 19 Mar 2018 12:50:49 +0100
changeset 22632 df853ecc851b
parent 22626 89f954dcc609
child 22826 ec2526db594c
permissions -rw-r--r--
#BUGFIX by mawalch class: AbstractTime added: #differenceFromTimestamp: Re-add.
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
21325
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
    55
iso8601FormatDocumentation
6172
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
"
21325
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   143
!
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   144
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   145
printFormatDocumentation
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   146
"
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   147
     bindings:
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   148
        %h      hours, 00..23 (i.e. european)  0-padded to length 2
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   149
        %u      hours, 00..12 (i.e. us)        0-padded to length 2
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   150
        %m      minutes, 00..59                0-padded to length 2
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   151
        %s      seconds, 00..59                0-padded to length 2
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   152
        %i      milliseconds, 000..999         0-padded to length 3
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   153
        %a      am/pm
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   154
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   155
     Timestamp only:
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   156
        %(day)   day, 00..31                    0-padded to length 2
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   157
        %(month) month, 00..12                  0-padded to length 2
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   158
        %(year)  year, 4 digits                 0-padded to length 4
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   159
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   160
     special:
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   161
        %H      24-hours - unpadded
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   162
        %U      12-hours - unpadded
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   163
        %M      minutes - unpadded
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   164
        %S      seconds - unpadded
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   165
        %I      milliseconds, unpadded
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   166
        %A      AM/PM   - uppercase
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   167
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   168
        %t      seconds within hour  (unpadded)
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   169
        %T      seconds from midNight  (unpadded)
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   170
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   171
        %(TZD)  timeZone delta of the receiver from UTC in the format +/-hh:mm
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   172
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   173
        %(milli1) milliseconds, truncated to 1/10th of a second 0..9
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   174
        %(milli2) milliseconds, truncated to 1/100th of a second 00..99 0-padded to length 2
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   175
        %(milli3) milliseconds, same as %i for convenience
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   176
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   177
     Timestamp only:
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   178
        %(Day)         - day - unpadded
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   179
        %(Month)       - month - unpadded
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   180
        %(yearOrTime)  - year or time 5 digits    as in unix-ls:
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   181
                                                  year if it is not the current year;
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   182
                                                  time otherwise
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   183
        %(weekDay)      - day in week (1->monday, 2->tuesday, ... ,7->sunday)
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   184
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   185
        %(dayName)      - full day name
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   186
        %(DayName)      - full day name, first character uppercase
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   187
        %(DAYNAME)      - full day name, all uppercase
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   188
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   189
        %(monthName)    - full month name
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   190
        %(MonthName)    - full month name, first character uppercase
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   191
        %(MONTHNAME)    - full month name, all uppercase
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   192
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   193
        %(shortDayName) - short (abbreviated) day name
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   194
        %(ShortDayName) - short (abbreviated) day name, first character uppercase
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   195
        %(SHORTDAYNAME) - short (abbreviated) day name, all uppercase
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   196
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   197
        %(shortMonthName) - short (abbreviated) month name
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   198
        %(ShortMonthName) - short (abbreviated) month name, first character uppercase
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   199
        %(SHORTMONTHNAME) - short (abbreviated) month name, all uppercase
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   200
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   201
        %(nth)          - counting day-in-month (1->'st'; 2->'nd'; 3->'rd'; 4...->'th')
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   202
        %(weekDayNth)   - counting day-in-week (1->'st'; 2->'nd'; 3->'rd'; 4...->'th')
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   203
        %(weekNth)      - counting week-in-year (1->'st'; 2->'nd'; 3->'rd'; 4...->'th')
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   204
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   205
        %(yearRoman)    - year, in roman letters
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   206
        %(monthRoman)   - month, in roman letters
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   207
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   208
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   209
     The ISO8601 printString are documented in iso8601FormatDocumentation:
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   210
"
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
   211
! !
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
   212
2310
2cb1366e0eb3 Correct name: #secondDay --> #secondInDay.
Stefan Vogel <sv@exept.de>
parents: 1500
diff changeset
   213
!AbstractTime class methodsFor:'instance creation'!
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
   214
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   215
dateAndTimeNow
1227
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   216
    "return an array filled with the current date and time.
16982
c37260d6ff78 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16941
diff changeset
   217
     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
   218
     See also: Date today / Time now / Timestamp now."
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
   219
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   220
    ^ Array with:(Date today) with:(Time now)
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
   221
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
   222
    "
16982
c37260d6ff78 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16941
diff changeset
   223
     Time dateAndTimeNow       
c37260d6ff78 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16941
diff changeset
   224
     Date dateAndTimeNow       
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
   225
    "
1227
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   226
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   227
    "Modified: 19.4.1996 / 15:23:37 / cg"
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   228
!
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
   229
9432
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
   230
epoch
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
   231
    "answer the time when we start counting"
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
   232
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
   233
    ^ self new setSeconds:0
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
   234
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
   235
    "
16982
c37260d6ff78 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16941
diff changeset
   236
     Timestamp epoch
c37260d6ff78 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16941
diff changeset
   237
     Time epoch     
9432
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
   238
    "
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
   239
!
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
   240
1227
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   241
now
19654
f07bf67efc5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19398
diff changeset
   242
    "return an instance of myself representing this moment with at least second precision.
16982
c37260d6ff78 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16941
diff changeset
   243
     Timestamps will redefine this to always return millisecond precision."
1227
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   244
1500
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
   245
    ^ self basicNew fromOSTime:(OperatingSystem getOSTime)
1227
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   246
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   247
    "
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   248
     Timestamp now   
1227
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   249
     Time now   
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   250
    "
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   251
1500
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
   252
    "Modified: 1.7.1996 / 15:20:10 / cg"
13233
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
   253
!
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
   254
22626
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   255
nowWithMicroseconds
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   256
    "return an instance of myself representing this moment with at least microsecond precision."
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   257
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   258
    |osTime millis micros|
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   259
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   260
    osTime := OperatingSystem getOSTimeWithMicros.
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   261
    millis := osTime at:1.
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   262
    micros := osTime at:2.
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   263
    ^ self basicNew fromOSTimeWithMilliseconds:millis picoseconds:(micros*(1000*1000)).
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   264
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   265
    "
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   266
     Timestamp now   
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   267
     Time now
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   268
     Timestamp nowWithMilliseconds
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   269
    "
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   270
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   271
    "Modified: 1.7.1996 / 15:20:10 / cg"
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   272
!
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   273
16941
78358165ed6b class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16934
diff changeset
   274
nowWithMilliseconds
22626
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   275
    "return an instance of myself representing this moment with at least millisecond precision."
16941
78358165ed6b class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16934
diff changeset
   276
78358165ed6b class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16934
diff changeset
   277
    ^ self basicNew fromOSTimeWithMilliseconds:(OperatingSystem getOSTime)
78358165ed6b class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16934
diff changeset
   278
78358165ed6b class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16934
diff changeset
   279
    "
22626
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   280
     Time now
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   281
     Time nowWithMilliseconds 
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   282
16941
78358165ed6b class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16934
diff changeset
   283
     Timestamp now   
22626
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   284
     Timestamp nowWithMilliseconds
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   285
     Timestamp nowWithMicroseconds
16941
78358165ed6b class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16934
diff changeset
   286
    "
78358165ed6b class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16934
diff changeset
   287
78358165ed6b class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16934
diff changeset
   288
    "Modified: 1.7.1996 / 15:20:10 / cg"
78358165ed6b class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16934
diff changeset
   289
!
78358165ed6b class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16934
diff changeset
   290
13233
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
   291
utcNow
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
   292
    "return an instance of myself representing this momentin the UTC timezone."
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
   293
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
   294
    ^ self subclassResponsibility
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
   295
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
   296
    "
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
   297
     Timestamp utcNow   
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
   298
     Timestamp utcNow
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
   299
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
   300
     Time now   
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
   301
     Time utcNow   
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
   302
    "
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
   303
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
   304
    "Modified: 1.7.1996 / 15:20:10 / cg"
1227
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   305
! !
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   306
7294
c4e6d095a150 category changes
Claus Gittinger <cg@exept.de>
parents: 7261
diff changeset
   307
!AbstractTime class methodsFor:'Compatibility-Squeak'!
7007
9af8cc2f82a4 totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents: 6888
diff changeset
   308
9432
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
   309
dateAndTimeFromSeconds:secondCount
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
   310
    "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
   311
9429
173bcd493d7c Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents: 8586
diff changeset
   312
    |timestamp|
173bcd493d7c Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents: 8586
diff changeset
   313
173bcd493d7c Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents: 8586
diff changeset
   314
"   
173bcd493d7c Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents: 8586
diff changeset
   315
    secondsBetween1901and1970 := 
9432
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
   316
        (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
   317
        *  (24 * 60 * 60)
173bcd493d7c Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents: 8586
diff changeset
   318
"
173bcd493d7c Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents: 8586
diff changeset
   319
9432
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
   320
    "stc cannot make large integers"
9449
6ba774be6aa1 stc can compile large integers!
Stefan Vogel <sv@exept.de>
parents: 9432
diff changeset
   321
    timestamp := Timestamp fromSeconds:secondCount - 2177452800.
7007
9af8cc2f82a4 totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents: 6888
diff changeset
   322
    ^ Array
9429
173bcd493d7c Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents: 8586
diff changeset
   323
        with: (timestamp asDate)
173bcd493d7c Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents: 8586
diff changeset
   324
        with: (timestamp asTime)
1227
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   325
7007
9af8cc2f82a4 totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents: 6888
diff changeset
   326
    "
9429
173bcd493d7c Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents: 8586
diff changeset
   327
     Timestamp dateAndTimeFromSeconds: (Time primSecondsClock) 
7007
9af8cc2f82a4 totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents: 6888
diff changeset
   328
     Time dateAndTimeFromSeconds: (Time totalSeconds) 
9af8cc2f82a4 totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents: 6888
diff changeset
   329
     Date dateAndTimeFromSeconds: (Time totalSeconds)
9af8cc2f82a4 totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents: 6888
diff changeset
   330
    "
9af8cc2f82a4 totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents: 6888
diff changeset
   331
!
9af8cc2f82a4 totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents: 6888
diff changeset
   332
11528
a617f1faef7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11518
diff changeset
   333
milliseconds:msTime1 since:msTime2
a617f1faef7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11518
diff changeset
   334
    "return the number of milliseconds between two
a617f1faef7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11518
diff changeset
   335
     millisecond time values, compensating for roll-over.
a617f1faef7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11518
diff changeset
   336
     The same as millisecondsBetween:and: for Squeak compatibility."
a617f1faef7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11518
diff changeset
   337
a617f1faef7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11518
diff changeset
   338
    ^ OperatingSystem millisecondTimeDeltaBetween:msTime1 and:msTime2
a617f1faef7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11518
diff changeset
   339
!
a617f1faef7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11518
diff changeset
   340
9926
5bfe280953b9 *** empty log message ***
Michael Beyl <mb@exept.de>
parents: 9449
diff changeset
   341
millisecondsSince: lastTime
5bfe280953b9 *** empty log message ***
Michael Beyl <mb@exept.de>
parents: 9449
diff changeset
   342
        "Answer the elapsed time since last recorded in milliseconds.
5bfe280953b9 *** empty log message ***
Michael Beyl <mb@exept.de>
parents: 9449
diff changeset
   343
        Compensate for rollover."
5bfe280953b9 *** empty log message ***
Michael Beyl <mb@exept.de>
parents: 9449
diff changeset
   344
5bfe280953b9 *** empty log message ***
Michael Beyl <mb@exept.de>
parents: 9449
diff changeset
   345
        ^self milliseconds: self millisecondClockValue since: lastTime
5bfe280953b9 *** empty log message ***
Michael Beyl <mb@exept.de>
parents: 9449
diff changeset
   346
!
5bfe280953b9 *** empty log message ***
Michael Beyl <mb@exept.de>
parents: 9449
diff changeset
   347
7007
9af8cc2f82a4 totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents: 6888
diff changeset
   348
primSecondsClock
9429
173bcd493d7c Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents: 8586
diff changeset
   349
    "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
   350
173bcd493d7c Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents: 8586
diff changeset
   351
    ^ Timestamp now utcSecondsSince1901
1227
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   352
20200
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
   353
    "
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
   354
     Timestamp primSecondsClock
9429
173bcd493d7c Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents: 8586
diff changeset
   355
    "
1227
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   356
! !
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   357
7294
c4e6d095a150 category changes
Claus Gittinger <cg@exept.de>
parents: 7261
diff changeset
   358
!AbstractTime class methodsFor:'Compatibility-VW'!
7007
9af8cc2f82a4 totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents: 6888
diff changeset
   359
9af8cc2f82a4 totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents: 6888
diff changeset
   360
totalSeconds
9429
173bcd493d7c Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents: 8586
diff changeset
   361
    "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
   362
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   363
    ^ Timestamp now utcSecondsSince1901
7007
9af8cc2f82a4 totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents: 6888
diff changeset
   364
! !
9af8cc2f82a4 totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents: 6888
diff changeset
   365
11130
fb6ebdb8c2a1 conversion errors
Claus Gittinger <cg@exept.de>
parents: 10907
diff changeset
   366
!AbstractTime class methodsFor:'error handling'!
fb6ebdb8c2a1 conversion errors
Claus Gittinger <cg@exept.de>
parents: 10907
diff changeset
   367
fb6ebdb8c2a1 conversion errors
Claus Gittinger <cg@exept.de>
parents: 10907
diff changeset
   368
conversionErrorSignal
fb6ebdb8c2a1 conversion errors
Claus Gittinger <cg@exept.de>
parents: 10907
diff changeset
   369
    "return the signal used for conversion error handling"
fb6ebdb8c2a1 conversion errors
Claus Gittinger <cg@exept.de>
parents: 10907
diff changeset
   370
fb6ebdb8c2a1 conversion errors
Claus Gittinger <cg@exept.de>
parents: 10907
diff changeset
   371
    ^ TimeConversionError
fb6ebdb8c2a1 conversion errors
Claus Gittinger <cg@exept.de>
parents: 10907
diff changeset
   372
! !
fb6ebdb8c2a1 conversion errors
Claus Gittinger <cg@exept.de>
parents: 10907
diff changeset
   373
13701
46009307d8e3 added: defaultFormatString
ca
parents: 13233
diff changeset
   374
!AbstractTime class methodsFor:'format strings'!
46009307d8e3 added: defaultFormatString
ca
parents: 13233
diff changeset
   375
46009307d8e3 added: defaultFormatString
ca
parents: 13233
diff changeset
   376
defaultFormatString
46009307d8e3 added: defaultFormatString
ca
parents: 13233
diff changeset
   377
    ^ '%h:%m:%s'
46009307d8e3 added: defaultFormatString
ca
parents: 13233
diff changeset
   378
! !
46009307d8e3 added: defaultFormatString
ca
parents: 13233
diff changeset
   379
18454
79aa7d84d07f class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 17400
diff changeset
   380
7258
9ccdbee7d1ad method category rename
Claus Gittinger <cg@exept.de>
parents: 7010
diff changeset
   381
!AbstractTime class methodsFor:'private-instance creation'!
1227
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   382
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   383
fromOSTime:osTime
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   384
    "return a time, representing the time given by the operatingSystem time.
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   385
     Not meant for public use."
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   386
1500
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
   387
    ^ self basicNew fromOSTime:osTime.
418
claus
parents: 384
diff changeset
   388
1500
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
   389
    "Modified: 1.7.1996 / 15:09:54 / cg"
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
   390
!
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
   391
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   392
fromSeconds:seconds
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   393
    "return an instance that is constructed from seconds.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   394
     This method is only allowed for second values as returned by
20200
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
   395
     getSeconds, possibly adding/subtracting to that.
1227
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   396
     Never depend on any specific interpretation of the seconds,
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   397
     since it depends on how the OperatingSystem counts time
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   398
     (some start at 1900, others with 1970 ...)"
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
   399
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   400
   ^ self basicNew setSeconds:seconds
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
   401
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
   402
    "
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   403
     Time fromSeconds:0             should return midnight
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   404
     Timestamp fromSeconds:0     on UNIX: returns 1st. Jan 1970
20789
4a410e6b1dff #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20200
diff changeset
   405
                                    on others: don't know
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   406
     (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
   407
        getSeconds                  on UNIX: returns 0
20200
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
   408
                                    on others: don't know
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   409
    "
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   410
1500
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
   411
    "Modified: 1.7.1996 / 13:39:30 / cg"
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
   412
! !
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
   413
2310
2cb1366e0eb3 Correct name: #secondDay --> #secondInDay.
Stefan Vogel <sv@exept.de>
parents: 1500
diff changeset
   414
!AbstractTime class methodsFor:'queries'!
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   415
18918
ea95a7e73213 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18454
diff changeset
   416
isAbstract
ea95a7e73213 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18454
diff changeset
   417
    ^ self == AbstractTime
ea95a7e73213 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18454
diff changeset
   418
!
ea95a7e73213 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18454
diff changeset
   419
15684
4c4bc53e32c8 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 14494
diff changeset
   420
microsecondClockValue
4c4bc53e32c8 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 14494
diff changeset
   421
    "return microseconds seconds of now"
4c4bc53e32c8 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 14494
diff changeset
   422
4c4bc53e32c8 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 14494
diff changeset
   423
    ^ OperatingSystem getMicrosecondTime
4c4bc53e32c8 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 14494
diff changeset
   424
4c4bc53e32c8 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 14494
diff changeset
   425
    "
4c4bc53e32c8 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 14494
diff changeset
   426
     Time microsecondClockValue
4c4bc53e32c8 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 14494
diff changeset
   427
    "
4c4bc53e32c8 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 14494
diff changeset
   428
4c4bc53e32c8 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 14494
diff changeset
   429
    "
4c4bc53e32c8 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 14494
diff changeset
   430
     |t1 t2 overhead|
4c4bc53e32c8 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 14494
diff changeset
   431
4c4bc53e32c8 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 14494
diff changeset
   432
     t1 := Time microsecondClockValue.
4c4bc53e32c8 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 14494
diff changeset
   433
     t2 := Time microsecondClockValue.
4c4bc53e32c8 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 14494
diff changeset
   434
     overhead := t2 - t1.  
4c4bc53e32c8 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 14494
diff changeset
   435
4c4bc53e32c8 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 14494
diff changeset
   436
     t1 := Time microsecondClockValue.
4c4bc53e32c8 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 14494
diff changeset
   437
     100 factorial.
4c4bc53e32c8 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 14494
diff changeset
   438
     t2 := Time microsecondClockValue.
4c4bc53e32c8 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 14494
diff changeset
   439
     t2 - t1 - overhead        
4c4bc53e32c8 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 14494
diff changeset
   440
    "
4c4bc53e32c8 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 14494
diff changeset
   441
!
4c4bc53e32c8 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 14494
diff changeset
   442
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   443
millisecondClockValue
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   444
    "return the millisecond clock - since this one overruns
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   445
     regularly, use the value only for short timing deltas.
5730
b377ec6357e7 comment
Claus Gittinger <cg@exept.de>
parents: 5573
diff changeset
   446
     Also remember that it wraps when comparing these values."
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   447
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   448
    ^ OperatingSystem getMillisecondTime.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   449
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   450
    "
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   451
     Time millisecondClockValue 
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   452
    "
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   453
!
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   454
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   455
secondClock
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   456
    "return seconds of now - for GNU-ST compatibility"
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   457
1500
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
   458
    ^ OperatingSystem getOSTime // 1000
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   459
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   460
    "
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   461
     AbstractTime secondClock    
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   462
    "
1500
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
   463
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
   464
    "Modified: 1.7.1996 / 15:20:14 / cg"
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   465
! !
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   466
18454
79aa7d84d07f class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 17400
diff changeset
   467
!AbstractTime class methodsFor:'reading'!
79aa7d84d07f class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 17400
diff changeset
   468
79aa7d84d07f class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 17400
diff changeset
   469
readFrom:aStringOrStream format:formatString
79aa7d84d07f class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 17400
diff changeset
   470
    "see format description in readFrom:format:language:onError:"
79aa7d84d07f class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 17400
diff changeset
   471
79aa7d84d07f class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 17400
diff changeset
   472
    ^ self 
79aa7d84d07f class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 17400
diff changeset
   473
        readFrom:aStringOrStream format:formatString language:nil 
79aa7d84d07f class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 17400
diff changeset
   474
        onError:[
19894
c03dc72fc13b #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 19654
diff changeset
   475
            self conversionErrorSignal raiseErrorString:' - Timestamp format error'
18454
79aa7d84d07f class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 17400
diff changeset
   476
        ].
79aa7d84d07f class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 17400
diff changeset
   477
!
79aa7d84d07f class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 17400
diff changeset
   478
19894
c03dc72fc13b #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 19654
diff changeset
   479
readFrom:aStringOrStream format:formatString language:languageString onError:exceptionalValue
c03dc72fc13b #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 19654
diff changeset
   480
    ^ self subclassResponsibility
c03dc72fc13b #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 19654
diff changeset
   481
!
c03dc72fc13b #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 19654
diff changeset
   482
18454
79aa7d84d07f class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 17400
diff changeset
   483
readFrom:aStringOrStream format:formatString onError:exceptionalValue
79aa7d84d07f class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 17400
diff changeset
   484
    "see format description in readFrom:format:language:onError:"
79aa7d84d07f class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 17400
diff changeset
   485
79aa7d84d07f class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 17400
diff changeset
   486
    ^ self readFrom:aStringOrStream format:formatString language:nil onError:exceptionalValue
79aa7d84d07f class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 17400
diff changeset
   487
! !
79aa7d84d07f class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 17400
diff changeset
   488
2310
2cb1366e0eb3 Correct name: #secondDay --> #secondInDay.
Stefan Vogel <sv@exept.de>
parents: 1500
diff changeset
   489
!AbstractTime class methodsFor:'timing evaluations'!
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   490
12831
97be4636cf07 added: #microsecondsToRun:
Stefan Vogel <sv@exept.de>
parents: 12662
diff changeset
   491
microsecondsToRun:aBlock
16673
38e6f4c80e3a fixed buggy copy pasta comment
az
parents: 16505
diff changeset
   492
    "evaluate the argument, aBlock; return the number of microseconds it took"
12831
97be4636cf07 added: #microsecondsToRun:
Stefan Vogel <sv@exept.de>
parents: 12662
diff changeset
   493
97be4636cf07 added: #microsecondsToRun:
Stefan Vogel <sv@exept.de>
parents: 12662
diff changeset
   494
    |startTime endTime|
97be4636cf07 added: #microsecondsToRun:
Stefan Vogel <sv@exept.de>
parents: 12662
diff changeset
   495
97be4636cf07 added: #microsecondsToRun:
Stefan Vogel <sv@exept.de>
parents: 12662
diff changeset
   496
    startTime := OperatingSystem getMicrosecondTime.
97be4636cf07 added: #microsecondsToRun:
Stefan Vogel <sv@exept.de>
parents: 12662
diff changeset
   497
    aBlock value.
97be4636cf07 added: #microsecondsToRun:
Stefan Vogel <sv@exept.de>
parents: 12662
diff changeset
   498
    endTime := OperatingSystem getMicrosecondTime.
97be4636cf07 added: #microsecondsToRun:
Stefan Vogel <sv@exept.de>
parents: 12662
diff changeset
   499
    ^ endTime - startTime
97be4636cf07 added: #microsecondsToRun:
Stefan Vogel <sv@exept.de>
parents: 12662
diff changeset
   500
97be4636cf07 added: #microsecondsToRun:
Stefan Vogel <sv@exept.de>
parents: 12662
diff changeset
   501
    "
97be4636cf07 added: #microsecondsToRun:
Stefan Vogel <sv@exept.de>
parents: 12662
diff changeset
   502
     Time microsecondsToRun:[1000 factorial]  
97be4636cf07 added: #microsecondsToRun:
Stefan Vogel <sv@exept.de>
parents: 12662
diff changeset
   503
    "
16673
38e6f4c80e3a fixed buggy copy pasta comment
az
parents: 16505
diff changeset
   504
38e6f4c80e3a fixed buggy copy pasta comment
az
parents: 16505
diff changeset
   505
    "Modified (comment): / 01-07-2014 / 15:57:13 / az"
12831
97be4636cf07 added: #microsecondsToRun:
Stefan Vogel <sv@exept.de>
parents: 12662
diff changeset
   506
!
97be4636cf07 added: #microsecondsToRun:
Stefan Vogel <sv@exept.de>
parents: 12662
diff changeset
   507
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   508
millisecondsToRun:aBlock
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   509
    "evaluate the argument, aBlock; return the number of milliseconds it took"
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   510
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   511
    |startTime endTime|
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   512
1476
02f69251f5bc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   513
    startTime := OperatingSystem getMillisecondTime.
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   514
    aBlock value.
1476
02f69251f5bc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   515
    endTime := OperatingSystem getMillisecondTime.
8586
a38e882affa5 take care of time-wrap in #millisecondsToRun:
Stefan Vogel <sv@exept.de>
parents: 8450
diff changeset
   516
    ^ self milliseconds:endTime since:startTime
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   517
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   518
    "
8586
a38e882affa5 take care of time-wrap in #millisecondsToRun:
Stefan Vogel <sv@exept.de>
parents: 8450
diff changeset
   519
     Time millisecondsToRun:[1000 factorial]  
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   520
    "
1476
02f69251f5bc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   521
02f69251f5bc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   522
    "Modified: 17.6.1996 / 16:57:37 / cg"
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   523
!
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   524
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   525
secondsToRun:aBlock
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   526
    "evaluate the argument, aBlock; return the number of seconds it took"
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   527
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   528
    |startTime endTime|
360
claus
parents: 275
diff changeset
   529
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   530
    startTime := self secondClock.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   531
    aBlock value.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   532
    endTime := self secondClock.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   533
    ^ endTime - startTime
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   534
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   535
    "
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   536
     Time secondsToRun:[1000 factorial]  
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   537
    "
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   538
! !
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   539
7261
f35fc9cee675 method category rename
Claus Gittinger <cg@exept.de>
parents: 7258
diff changeset
   540
!AbstractTime methodsFor:'Compatibility-ANSI'!
6419
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   541
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   542
hour12
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   543
    "return the hour (1..12)."
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   544
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   545
    ^ self hours - 1 \\ 12 + 1.
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   546
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   547
    "
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   548
     Time now hour12   
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   549
     Time now hour24   
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   550
     (Time hours:0 minutes:0 seconds:0) hour24   
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   551
     (Time hours:0 minutes:0 seconds:0) hour12   
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   552
     (Time hours:1 minutes:0 seconds:0) hour24   
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   553
     (Time hours:1 minutes:0 seconds:0) hour12   
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   554
     (Time hours:12 minutes:0 seconds:0) hour24 
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   555
     (Time hours:12 minutes:0 seconds:0) hour12   
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   556
     (Time hours:13 minutes:0 seconds:0) hour24 
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   557
     (Time hours:13 minutes:0 seconds:0) hour12   
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   558
     (Time hours:23 minutes:0 seconds:0) hour24 
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   559
     (Time hours:23 minutes:0 seconds:0) hour12   
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   560
     (Time hours:24 minutes:0 seconds:0) hour24 
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   561
     (Time hours:24 minutes:0 seconds:0) hour12   
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   562
    "
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   563
!
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   564
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   565
hour24
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   566
    "return the hour (0..23)."
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   567
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   568
    ^ self hours
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   569
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   570
    "
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   571
     Time now hour12   
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   572
     Time now hour24   
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   573
     (Time hours:0 minutes:0 seconds:0) hour24 
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   574
     (Time hours:0 minutes:0 seconds:0) hour12 
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   575
     (Time hours:1 minutes:0 seconds:0) hour24 
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   576
     (Time hours:1 minutes:0 seconds:0) hour12 
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   577
     (Time hours:12 minutes:0 seconds:0) hour24 
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   578
     (Time hours:12 minutes:0 seconds:0) hour12 
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   579
     (Time hours:13 minutes:0 seconds:0) hour24 
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   580
     (Time hours:13 minutes:0 seconds:0) hour12 
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   581
     (Time hours:23 minutes:0 seconds:0) hour24 
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   582
     (Time hours:23 minutes:0 seconds:0) hour12 
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   583
     (Time hours:24 minutes:0 seconds:0) hour24 
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   584
     (Time hours:24 minutes:0 seconds:0) hour12 
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   585
    "
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   586
!
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   587
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   588
meridianAbbreviation
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   589
    "am/pm"
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   590
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   591
    self hours // 12 == 0 ifTrue:[
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   592
        ^ 'am'.
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   593
    ] ifFalse:[
8200
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   594
        (self hours == 12 and:[self minutes == 0 and:[self seconds == 0]]) ifTrue:[
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   595
            ^ 'noon'
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   596
        ].
6419
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   597
        ^ 'pm'.
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   598
    ].
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   599
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   600
    "
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   601
     Time now meridianAbbreviation   
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   602
     (Time hours:0 minutes:0 seconds:0) meridianAbbreviation  
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   603
     (Time hours:11 minutes:59 seconds:59) meridianAbbreviation  
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   604
     (Time hours:12 minutes:0 seconds:0) meridianAbbreviation    
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   605
     (Time hours:12 minutes:0 seconds:1) meridianAbbreviation  
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   606
    "
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   607
! !
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   608
22632
df853ecc851b #BUGFIX by mawalch
mawalch
parents: 22626
diff changeset
   609
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   610
!AbstractTime methodsFor:'abstract'!
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   611
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   612
hours
8200
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   613
    "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
   614
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   615
    ^ self subclassResponsibility
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   616
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   617
    "
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   618
     Timestamp now hours 
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   619
     Time now hours 
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   620
    "
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   621
!
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   622
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   623
milliseconds
8200
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   624
    "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
   625
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   626
    ^ self subclassResponsibility
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   627
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   628
    "
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   629
     Timestamp now milliseconds 
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   630
     Time now milliseconds 
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   631
    "
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   632
!
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   633
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   634
minutes
8200
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   635
    "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
   636
7672
46f206594db3 Category change
Stefan Vogel <sv@exept.de>
parents: 7327
diff changeset
   637
    ^ self subclassResponsibility.
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   638
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   639
    "
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   640
     Timestamp now minutes 
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   641
     Time now minutes 
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   642
    "
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   643
!
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   644
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   645
seconds
8200
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   646
    "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
   647
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   648
    ^ self subclassResponsibility
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   649
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   650
    "
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   651
     Timestamp now seconds. 
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   652
     Time now seconds 
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   653
    "
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   654
! !
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   655
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   656
!AbstractTime methodsFor:'accessing'!
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   657
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   658
hourInDay
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   659
    "return the hours (0..23)"
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   660
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   661
    ^ self hours
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   662
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   663
    "
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   664
     Timestamp now hourInDay 
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   665
     Time now hourInDay 
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   666
    "
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   667
!
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   668
22626
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   669
microseconds
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   670
    "return the microseconds within the current second (0..999999)"
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   671
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   672
    ^ (self milliseconds * 1000) + (self picoseconds // (1000*1000)).
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   673
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   674
    "
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   675
     Timestamp now microseconds   
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   676
     Timestamp nowWithMicroseconds microseconds   
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   677
    "
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   678
!
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   679
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   680
minuteInDay
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   681
    "return the minutes (0..59)"
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   682
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   683
    ^ self minutes.
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   684
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   685
    "
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   686
     Timestamp now minuteInDay 
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   687
     Time now minuteInDay 
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   688
    "
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   689
!
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   690
22626
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   691
picoseconds
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   692
    "return the additional picoseconds within the current second (0..999999999).
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   693
     Here, assume that we have none"
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   694
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   695
    ^ 0.
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   696
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   697
    "
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   698
     Timestamp now picoseconds
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   699
    "
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   700
!
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   701
2310
2cb1366e0eb3 Correct name: #secondDay --> #secondInDay.
Stefan Vogel <sv@exept.de>
parents: 1500
diff changeset
   702
secondInDay
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   703
    "return the seconds (0..59)"
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   704
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   705
    ^ self seconds
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   706
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   707
    "
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   708
     Timestamp now secondInDay 
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   709
     Time now seconds 
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   710
    "
2310
2cb1366e0eb3 Correct name: #secondDay --> #secondInDay.
Stefan Vogel <sv@exept.de>
parents: 1500
diff changeset
   711
2cb1366e0eb3 Correct name: #secondDay --> #secondInDay.
Stefan Vogel <sv@exept.de>
parents: 1500
diff changeset
   712
    "Created: 22.10.1996 / 09:27:47 / stefan"
5548
eead51e4752e added #weekInYear query
Claus Gittinger <cg@exept.de>
parents: 5191
diff changeset
   713
!
eead51e4752e added #weekInYear query
Claus Gittinger <cg@exept.de>
parents: 5191
diff changeset
   714
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   715
timeZoneDeltaInMinutes
9432
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
   716
    "answer the number of minutes between local time and utc time.
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
   717
     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
   718
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   719
    ^ 0
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   720
!
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   721
5968
4832ed93f0b4 preps for timeZone
Claus Gittinger <cg@exept.de>
parents: 5964
diff changeset
   722
timeZoneName
16982
c37260d6ff78 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16941
diff changeset
   723
    ^ 'UTC'
c37260d6ff78 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16941
diff changeset
   724
!
c37260d6ff78 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16941
diff changeset
   725
c37260d6ff78 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16941
diff changeset
   726
utcOffset
c37260d6ff78 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16941
diff changeset
   727
    ^ 0
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   728
! !
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   729
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   730
!AbstractTime methodsFor:'arithmetic'!
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   731
10679
b4dd3412ce74 adding timeDurations to a timeStamp (double dispatch)
sr
parents: 10485
diff changeset
   732
+ aNumberOrTimeDuration
21427
26521b634779 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21335
diff changeset
   733
    "Add aNumber numberOfSeconds or, if it's a timeDuration, add it's value"
8200
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   734
10679
b4dd3412ce74 adding timeDurations to a timeStamp (double dispatch)
sr
parents: 10485
diff changeset
   735
    ^ aNumberOrTimeDuration sumFromTimestamp:self.
b4dd3412ce74 adding timeDurations to a timeStamp (double dispatch)
sr
parents: 10485
diff changeset
   736
17015
f7c4867a3633 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16982
diff changeset
   737
"/    ^ self speciesNew 
10679
b4dd3412ce74 adding timeDurations to a timeStamp (double dispatch)
sr
parents: 10485
diff changeset
   738
"/        setMilliseconds:(self getMilliseconds + (aNumberOrTimeDuration * 1000) asInteger)
8200
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   739
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   740
    "
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   741
     Timestamp now to:(Timestamp now + 30) by:2 do:[:time|
8200
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   742
        Transcript showCR:time.
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   743
     ].
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   744
10679
b4dd3412ce74 adding timeDurations to a timeStamp (double dispatch)
sr
parents: 10485
diff changeset
   745
     (Timestamp now + 20)  -  Timestamp now  
b4dd3412ce74 adding timeDurations to a timeStamp (double dispatch)
sr
parents: 10485
diff changeset
   746
     (Timestamp now + 0.5)  -  Timestamp now  
b4dd3412ce74 adding timeDurations to a timeStamp (double dispatch)
sr
parents: 10485
diff changeset
   747
     (Timestamp now + (TimeDuration fromString:'1m 10s'))  -  Timestamp now  
11771
1c6251b7286d comment
Claus Gittinger <cg@exept.de>
parents: 11528
diff changeset
   748
     (Timestamp now + (10 seconds))  -  Timestamp now  
8200
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   749
    "
21427
26521b634779 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21335
diff changeset
   750
26521b634779 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21335
diff changeset
   751
    "Modified (comment): / 13-02-2017 / 19:55:04 / cg"
8200
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   752
!
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   753
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   754
- aTimeOrNumberOfSeconds
8244
06543e00260e comment
Claus Gittinger <cg@exept.de>
parents: 8200
diff changeset
   755
    "return the delta in seconds between 2 times or subtract a number of seconds."
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   756
11515
d467ba9dc495 double dispatch for subtract (time - time; time - nr)
sr
parents: 11130
diff changeset
   757
    ^ aTimeOrNumberOfSeconds differenceFromTimestamp:self.
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   758
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   759
    "
11518
8b4cafbd318a double dispatch for time-difference
sr
parents: 11515
diff changeset
   760
     Timestamp now - 3600.  
11515
d467ba9dc495 double dispatch for subtract (time - time; time - nr)
sr
parents: 11130
diff changeset
   761
     Time now - 3600.   
11518
8b4cafbd318a double dispatch for time-difference
sr
parents: 11515
diff changeset
   762
     (Time now addSeconds:10) - Time now   
11515
d467ba9dc495 double dispatch for subtract (time - time; time - nr)
sr
parents: 11130
diff changeset
   763
     (TimeDuration fromString:'1.5hr') - 3600.   
d467ba9dc495 double dispatch for subtract (time - time; time - nr)
sr
parents: 11130
diff changeset
   764
     (TimeDuration fromString:'1.5hr') - (TimeDuration fromString:'1hr')   
8200
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   765
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   766
     |t1 t2|
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   767
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   768
     t1 := Timestamp now.
16407
67eeb7ae5eb8 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16365
diff changeset
   769
     Delay waitFor:10 seconds.
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   770
     t2 := Timestamp now.
3476
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   771
     Transcript showCR:('seconds passed: ' , (t2 - t1) printString).
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   772
    "
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   773
!
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   774
6048
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   775
addDays:numberOfDays
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   776
    "return a new instance of myself, numberOfDays afterwards."
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   777
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   778
    ^ self addSeconds:(numberOfDays * (60 * 60 * 24))
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   779
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   780
    "
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   781
     |t|
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   782
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   783
     t := Timestamp now.
6048
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   784
     Transcript showCR:t.
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   785
     Transcript showCR:(t addDays:7)
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   786
    "
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   787
!
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   788
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   789
addHours:numberOfHours
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   790
    "return a new instance of myself, numberOfHours afterwards."
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   791
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   792
    ^ self addSeconds:(numberOfHours * (60 * 60))
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   793
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   794
    "
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   795
     |t|
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   796
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   797
     t := Timestamp now.
3476
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   798
     Transcript showCR:t.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   799
     Transcript showCR:(t addHours:12).
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   800
    "
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   801
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   802
    "
3476
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   803
     |t|
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   804
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   805
     t := Time now.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   806
     Transcript showCR:t.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   807
     Transcript showCR:(t addHours:12).
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   808
    "
6043
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   809
!
3476
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   810
6043
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   811
addMilliseconds:numberOfMilliSeconds
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   812
    "return a new instance of myself, numberOfMilliSeconds afterwards."
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   813
17015
f7c4867a3633 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16982
diff changeset
   814
    ^ self speciesNew 
6043
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   815
        setMilliseconds:(self getMilliseconds + numberOfMilliSeconds)
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   816
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   817
    "
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   818
     |t|
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   819
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   820
     t := Timestamp now.
6043
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   821
     Transcript showCR:t.
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   822
     Transcript showCR:(t addMilliseconds:100).
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   823
    "
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   824
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   825
    "
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   826
     |t|
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   827
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   828
     t := Time now.
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   829
     Transcript showCR:t.
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   830
     Transcript showCR:(t addMilliseconds:1000).
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   831
    "
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   832
!
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   833
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   834
addMinutes:numberOfMinutes
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   835
    "return a new instance of myself, numberOfMinutes afterwards."
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   836
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   837
    ^ self addSeconds:(numberOfMinutes * 60)
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   838
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   839
    "
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   840
     |t|
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   841
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   842
     t := Timestamp now.
3476
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   843
     Transcript showCR:t.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   844
     Transcript showCR:(t addMinutes:60).
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   845
    "
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   846
3476
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   847
    "
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   848
     |t|
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   849
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   850
     t := Time now.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   851
     Transcript showCR:t.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   852
     Transcript showCR:(t addMinutes:60).
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   853
    "
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   854
!
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   855
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   856
addSeconds:numberOfSeconds
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   857
    "return a new instance of myself, numberOfSeconds afterwards."
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   858
17015
f7c4867a3633 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16982
diff changeset
   859
    ^ self speciesNew 
3476
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   860
        setMilliseconds:(self getMilliseconds + (numberOfSeconds * 1000))
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
     |t|
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   864
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   865
     t := Timestamp now.
3476
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   866
     Transcript showCR:t.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   867
     Transcript showCR:(t addSeconds:60).
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   868
    "
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   869
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   870
    "
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   871
     |t|
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   872
3476
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   873
     t := Time now.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   874
     Transcript showCR:t.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   875
     Transcript showCR:(t addSeconds:60).
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   876
    "
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   877
!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   878
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   879
addTime:timeAmount
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   880
    "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
   881
     Provided for ST-80 compatibility.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   882
     WARNING:
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   883
        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
   884
        a numberOfSeconds as argument. 
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   885
        Use any of addSeconds/addHours etc. to make things clear"
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   886
6888
d75cbe2e8ef7 addTime / subtractTime handle non-Number argument
Claus Gittinger <cg@exept.de>
parents: 6795
diff changeset
   887
    timeAmount isNumber ifFalse:[
d75cbe2e8ef7 addTime / subtractTime handle non-Number argument
Claus Gittinger <cg@exept.de>
parents: 6795
diff changeset
   888
        ^ self addSeconds:(timeAmount asSeconds).
d75cbe2e8ef7 addTime / subtractTime handle non-Number argument
Claus Gittinger <cg@exept.de>
parents: 6795
diff changeset
   889
    ].
3476
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   890
    ^ self addSeconds:timeAmount
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   891
!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   892
16475
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
   893
deltaFrom:aTimeOrInteger
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
   894
    "return the delta as a timeDuration between 2 timeStamps.
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
   895
     The argument is supposed to be BEFORE the receiver,
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
   896
        computes self - aTimestamp"
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
   897
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
   898
    ^ aTimeOrInteger differenceFromTimestamp:self
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
   899
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
   900
    "
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
   901
        Time now deltaFrom:10 minutes.
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
   902
        Time now deltaFrom:3600.
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
   903
        Time now deltaFrom:3600 seconds.
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
   904
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
   905
        Timestamp now deltaFrom:10 minutes.
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
   906
        Timestamp now deltaFrom:3600.
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
   907
        Timestamp now deltaFrom:3600 seconds.
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
   908
    "
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
   909
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
   910
    "
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
   911
     |t1 t2|
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
   912
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
   913
     t1 := Timestamp now.
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
   914
     Delay waitForSeconds:0.5.
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
   915
     t2 := Timestamp now.
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
   916
     t2 deltaFrom:t1   
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
   917
    "
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
   918
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
   919
    "Created: / 04-10-2007 / 13:34:28 / cg"
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
   920
    "Modified: / 10-07-2010 / 09:37:01 / cg"
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
   921
!
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
   922
16505
c285d94f2248 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16475
diff changeset
   923
roundTo:aTimeDuration
21335
74daa1537978 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21325
diff changeset
   924
    "round the receiver to the next multiple of a TimeDuration"
74daa1537978 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21325
diff changeset
   925
    
16505
c285d94f2248 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16475
diff changeset
   926
     ^ self class new setMilliseconds:(self getMilliseconds roundTo:aTimeDuration getMilliseconds)
c285d94f2248 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16475
diff changeset
   927
c285d94f2248 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16475
diff changeset
   928
    "
c285d94f2248 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16475
diff changeset
   929
      (TimeDuration fromMilliseconds:25234) roundTo:2 seconds
c285d94f2248 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16475
diff changeset
   930
      Time now roundTo:10 minutes
c285d94f2248 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16475
diff changeset
   931
      Timestamp now roundTo:10 minutes
c285d94f2248 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16475
diff changeset
   932
    "
c285d94f2248 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16475
diff changeset
   933
!
c285d94f2248 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16475
diff changeset
   934
6048
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   935
subtractDays:numberOfDays
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   936
    "return a new instance of myself, numberOfDays before."
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   937
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   938
    ^ self subtractSeconds:(numberOfDays * (60 * 60 * 24))
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   939
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   940
    "
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   941
     |t|
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   942
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   943
     t := Timestamp now.
6048
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   944
     Transcript showCR:t.
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   945
     Transcript showCR:(t subtractDays:50)
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   946
    "
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   947
!
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   948
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   949
subtractHours:numberOfHours
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   950
    "return a new instance of myself, numberOfHours before."
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   951
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   952
    ^ self subtractSeconds:(numberOfHours * (60 * 60))
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   953
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   954
    "
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   955
     |t|
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   956
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   957
     t := Timestamp now.
3476
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   958
     Transcript showCR:t.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   959
     Transcript showCR:(t subtractHours:12).
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   960
    "
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   961
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   962
    "
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   963
     |t|
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   964
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   965
     t := Time now.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   966
     Transcript showCR:t.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   967
     Transcript showCR:(t subtractHours:12).
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   968
    "
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   969
!
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   970
6043
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   971
subtractMilliseconds:numberOfMilliSeconds
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   972
    "return a new instance of myself, numberOfMilliSeconds before."
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   973
17015
f7c4867a3633 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16982
diff changeset
   974
    ^ self speciesNew 
6043
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   975
        setMilliseconds:(self getMilliseconds - numberOfMilliSeconds)
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   976
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   977
    "
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   978
     |t|
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   979
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   980
     t := Timestamp now.
6043
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   981
     Transcript showCR:t.
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   982
     Transcript showCR:(t subtractMilliseconds:100).
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   983
    "
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   984
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   985
    "
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   986
     |t|
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   987
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   988
     t := Time now.
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   989
     Transcript showCR:t.
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   990
     Transcript showCR:(t subtractMilliseconds:1000).
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   991
    "
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   992
!
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   993
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   994
subtractMinutes:numberOfMinutes
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   995
    "return a new instance of myself, numberOfMinutes before."
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   996
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   997
    ^ self subtractSeconds:(numberOfMinutes * 60)
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   998
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   999
    "
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
  1000
     |t|
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
  1001
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
  1002
     t := Timestamp now.
3476
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  1003
     Transcript showCR:t.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  1004
     Transcript showCR:(t subtractMinutes:60).
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  1005
    "
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  1006
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  1007
    "
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  1008
     |t|
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  1009
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  1010
     t := Time now.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  1011
     Transcript showCR:t.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  1012
     Transcript showCR:(t subtractMinutes:60).
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
  1013
    "
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
  1014
!
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
  1015
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1016
subtractSeconds:numberOfSeconds
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1017
    "return a new instance of myself, numberOfSeconds before."
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
  1018
17015
f7c4867a3633 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16982
diff changeset
  1019
    ^ self speciesNew 
3476
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  1020
        setMilliseconds:(self getMilliseconds - (numberOfSeconds * 1000))
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
  1021
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
  1022
    "
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
  1023
     |t|
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
  1024
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
  1025
     t := Timestamp now.
3476
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  1026
     Transcript showCR:t.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  1027
     Transcript showCR:(t subtractSeconds:60).
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  1028
    "
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  1029
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
  1030
    "
3476
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  1031
     |t|
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  1032
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  1033
     t := Time now.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  1034
     Transcript showCR:t.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  1035
     Transcript showCR:(t subtractSeconds:60).
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  1036
    "
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
  1037
!
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
  1038
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
  1039
subtractTime:timeAmount
3476
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  1040
    "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
  1041
     Provided for ST-80 compatibility.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  1042
     WARNING:
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  1043
        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
  1044
        a numberOfSeconds as argument. 
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  1045
        Use any of addSeconds/addHours etc. to make things clear"
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
  1046
6888
d75cbe2e8ef7 addTime / subtractTime handle non-Number argument
Claus Gittinger <cg@exept.de>
parents: 6795
diff changeset
  1047
    timeAmount isNumber ifFalse:[
d75cbe2e8ef7 addTime / subtractTime handle non-Number argument
Claus Gittinger <cg@exept.de>
parents: 6795
diff changeset
  1048
        ^ self subtractSeconds:(timeAmount asSeconds).
d75cbe2e8ef7 addTime / subtractTime handle non-Number argument
Claus Gittinger <cg@exept.de>
parents: 6795
diff changeset
  1049
    ].
3476
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  1050
    ^ self subtractSeconds:timeAmount
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  1051
16505
c285d94f2248 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16475
diff changeset
  1052
!
c285d94f2248 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16475
diff changeset
  1053
c285d94f2248 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16475
diff changeset
  1054
truncateTo:aTimeDuration
21335
74daa1537978 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21325
diff changeset
  1055
    "truncate the receiver to the next multiple of a TimeDuration"
74daa1537978 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21325
diff changeset
  1056
16505
c285d94f2248 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16475
diff changeset
  1057
     ^ self class new setMilliseconds:(self getMilliseconds truncateTo:aTimeDuration getMilliseconds)
c285d94f2248 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16475
diff changeset
  1058
c285d94f2248 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16475
diff changeset
  1059
    "
c285d94f2248 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16475
diff changeset
  1060
      (TimeDuration fromMilliseconds:25234) truncateTo:2 seconds
c285d94f2248 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16475
diff changeset
  1061
      Time now truncateTo:10 minutes
c285d94f2248 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16475
diff changeset
  1062
      Timestamp now truncateTo:10 minutes
c285d94f2248 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16475
diff changeset
  1063
    "
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
  1064
! !
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
  1065
5573
efd0dc6578ac #-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 5548
diff changeset
  1066
!AbstractTime methodsFor:'comparing'!
efd0dc6578ac #-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 5548
diff changeset
  1067
efd0dc6578ac #-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 5548
diff changeset
  1068
< aTime
efd0dc6578ac #-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 5548
diff changeset
  1069
    "return true if the receiver is before the argument"
efd0dc6578ac #-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 5548
diff changeset
  1070
efd0dc6578ac #-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 5548
diff changeset
  1071
    ^ self getMilliseconds < aTime getMilliseconds
efd0dc6578ac #-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 5548
diff changeset
  1072
efd0dc6578ac #-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 5548
diff changeset
  1073
    "Modified: 3.7.1996 / 13:10:17 / cg"
efd0dc6578ac #-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 5548
diff changeset
  1074
!
efd0dc6578ac #-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 5548
diff changeset
  1075
efd0dc6578ac #-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 5548
diff changeset
  1076
> aTime
efd0dc6578ac #-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 5548
diff changeset
  1077
    "return true if the receiver is after the argument"
efd0dc6578ac #-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 5548
diff changeset
  1078
efd0dc6578ac #-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 5548
diff changeset
  1079
    ^ self getMilliseconds > aTime getMilliseconds
efd0dc6578ac #-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 5548
diff changeset
  1080
efd0dc6578ac #-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 5548
diff changeset
  1081
    "Modified: 1.7.1996 / 15:24:38 / cg"
efd0dc6578ac #-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 5548
diff changeset
  1082
! !
efd0dc6578ac #-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 5548
diff changeset
  1083
8200
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
  1084
!AbstractTime methodsFor:'converting'!
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
  1085
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
  1086
asAbsoluteTime
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
  1087
    "deprecated, use #asTimestamp"
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
  1088
    <resource:#obsolete>
8200
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
  1089
12002
3ecffb2d77ad *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11772
diff changeset
  1090
    self obsoleteMethodWarning:'use #asTimestamp'.
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
  1091
    ^ self asTimestamp
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
  1092
!
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
  1093
13233
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
  1094
asLocalTimestamp
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
  1095
    "represent myself as a timestamp in the local timezone"
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
  1096
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
  1097
    ^ self subclassResponsibility
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
  1098
!
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
  1099
17140
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
  1100
asMilliseconds
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
  1101
    "return the number of milliseconds elapsed since midnight"
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
  1102
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
  1103
    ^ self getMilliseconds
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
  1104
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
  1105
    "
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
  1106
     Time now asMilliseconds
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
  1107
     Timestamp now asMilliseconds
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
  1108
     (TimeDuration days:1) asMilliseconds
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
  1109
     (TimeDuration hours:1) asMilliseconds
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
  1110
    "
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
  1111
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
  1112
    "Created: / 05-09-2011 / 10:40:15 / cg"
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
  1113
!
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
  1114
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
  1115
asSeconds
19398
7384b2086a5d #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 19198
diff changeset
  1116
    "get the seconds since some point of time in the past.
7384b2086a5d #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 19198
diff changeset
  1117
     For Time instances, this is the number of seconds elapsed since midnight;
22283
3edefecbb6b6 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22036
diff changeset
  1118
     For TimeDurations, that is the duration in seconds (truncated);
19398
7384b2086a5d #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 19198
diff changeset
  1119
     For TimeStamps, that is the number of seconds since the epoch"
17140
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
  1120
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
  1121
    ^ self getSeconds
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
  1122
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
  1123
    "
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
  1124
     Timestamp now asSeconds
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
  1125
     Time now asSeconds
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
  1126
     (TimeDuration days:1) asSeconds
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
  1127
    "
22283
3edefecbb6b6 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22036
diff changeset
  1128
3edefecbb6b6 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22036
diff changeset
  1129
    "Modified (comment): / 21-09-2017 / 18:49:31 / cg"
17140
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
  1130
!
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
  1131
22036
bb2ede52a8f0 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21671
diff changeset
  1132
asTime
bb2ede52a8f0 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21671
diff changeset
  1133
    "return a Time object from the receiver."
bb2ede52a8f0 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21671
diff changeset
  1134
bb2ede52a8f0 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21671
diff changeset
  1135
    ^ Time hours:(self hours) minutes:(self minutes) seconds:(self seconds) milliseconds:(self milliseconds)
bb2ede52a8f0 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21671
diff changeset
  1136
bb2ede52a8f0 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21671
diff changeset
  1137
    "
bb2ede52a8f0 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21671
diff changeset
  1138
     (1 seconds + 0.01 seconds) asTime
bb2ede52a8f0 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21671
diff changeset
  1139
    "
bb2ede52a8f0 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21671
diff changeset
  1140
bb2ede52a8f0 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21671
diff changeset
  1141
    "Created: / 17-07-2017 / 13:57:54 / cg"
bb2ede52a8f0 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21671
diff changeset
  1142
!
bb2ede52a8f0 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21671
diff changeset
  1143
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
  1144
asTimestamp
13233
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
  1145
    "represent myself as a Timestamp"
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
  1146
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
  1147
    ^ self subclassResponsibility
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
  1148
!
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
  1149
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
  1150
asUtcTimestamp
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
  1151
    "represent myself as a timestamp in the local timezone"
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
  1152
8200
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
  1153
    ^ self subclassResponsibility
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
  1154
! !
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
  1155
22632
df853ecc851b #BUGFIX by mawalch
mawalch
parents: 22626
diff changeset
  1156
!AbstractTime methodsFor:'double dispatching'!
df853ecc851b #BUGFIX by mawalch
mawalch
parents: 22626
diff changeset
  1157
df853ecc851b #BUGFIX by mawalch
mawalch
parents: 22626
diff changeset
  1158
differenceFromTimestamp:aTimestamp
df853ecc851b #BUGFIX by mawalch
mawalch
parents: 22626
diff changeset
  1159
    "/ the correct thing to do (and I will, in the future) is to
df853ecc851b #BUGFIX by mawalch
mawalch
parents: 22626
diff changeset
  1160
    "/ return a TimeDuration:
df853ecc851b #BUGFIX by mawalch
mawalch
parents: 22626
diff changeset
  1161
    "/
df853ecc851b #BUGFIX by mawalch
mawalch
parents: 22626
diff changeset
  1162
    ^ TimeDuration fromMilliseconds:(aTimestamp getMilliseconds - self getMilliseconds).
df853ecc851b #BUGFIX by mawalch
mawalch
parents: 22626
diff changeset
  1163
df853ecc851b #BUGFIX by mawalch
mawalch
parents: 22626
diff changeset
  1164
    "/ which is the same as: deltaFrom:aTimestamp
df853ecc851b #BUGFIX by mawalch
mawalch
parents: 22626
diff changeset
  1165
    "/
df853ecc851b #BUGFIX by mawalch
mawalch
parents: 22626
diff changeset
  1166
    "/ however, there might be old code around, which is not be prepared for
df853ecc851b #BUGFIX by mawalch
mawalch
parents: 22626
diff changeset
  1167
    "/ getting a non-number (the seconds). Therefore, for the meantime,
df853ecc851b #BUGFIX by mawalch
mawalch
parents: 22626
diff changeset
  1168
    "/ we return:
df853ecc851b #BUGFIX by mawalch
mawalch
parents: 22626
diff changeset
  1169
df853ecc851b #BUGFIX by mawalch
mawalch
parents: 22626
diff changeset
  1170
    "/ ^ aTimestamp getSeconds - self getSeconds
df853ecc851b #BUGFIX by mawalch
mawalch
parents: 22626
diff changeset
  1171
! !
df853ecc851b #BUGFIX by mawalch
mawalch
parents: 22626
diff changeset
  1172
11518
8b4cafbd318a double dispatch for time-difference
sr
parents: 11515
diff changeset
  1173
4649
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1174
!AbstractTime methodsFor:'printing & storing'!
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1175
16829
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1176
addBasicPrintBindingsTo:aDictionary language:languageOrNil
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1177
    "private print support: add bindings for printing to aDictionary.
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1178
     languageOrNil can be #en, #fr, #de or nil for the current language.
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1179
     Here only basic bindings are added - no timezone am am/pm stuff,
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1180
     which doesn't make sense for TimeDuration.
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1181
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1182
     bindings:
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1183
        %h      hours, 00..23 (i.e. european)  0-padded to length 2
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1184
        %m      minutes, 00..59                0-padded to length 2
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1185
        %s      seconds, 00..59                0-padded to length 2
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1186
        %i      milliseconds, 000..999         0-padded to length 3
22626
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1187
        %j      microseconds, 000000..999999   0-padded to length 6
16829
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1188
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1189
     Timestamp only:
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1190
        %(day)   day, 00..31                    0-padded to length 2
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1191
        %(month) month, 00..12                  0-padded to length 2
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1192
        %(year)  year, 4 digits                 0-padded to length 4
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1193
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1194
     special:
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1195
        %H      24-hours - unpadded
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1196
        %M      minutes - unpadded
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1197
        %S      seconds - unpadded
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1198
        %I      milliseconds, unpadded
22626
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1199
        %J      microseconds, unpadded
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1200
        %F      subsecond fraction, unpadded with as many post-digits as appropriate
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1201
                (i.e. for .1 , .01 , .001 etc.)
16829
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1202
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1203
        %t      seconds within hour  (unpadded)
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1204
        %T      seconds from midNight  (unpadded)
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1205
22626
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1206
        %(milli) milliseconds unpadded - alias for %I for convenience
20200
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1207
        %(milli1) milliseconds, truncated to 1/10th of a second 0..9
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1208
        %(milli2) milliseconds, truncated to 1/100th of a second 00..99 0-padded to length 2
16829
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1209
        %(milli3) milliseconds, same as %i for convenience
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1210
22626
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1211
        %(micro) microseconds unpadded - alias for %J for convenience
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1212
        %(micro6) microseconds, same as %j for convenience
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1213
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1214
        %(fract) fraction part - alias for %F for convenience
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1215
16829
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1216
     Timestamp only:
20200
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1217
        %(Day)         - day - unpadded
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1218
        %(Month)       - month - unpadded
16829
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1219
        %(yearOrTime)  - year or time 5 digits    as in unix-ls:
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1220
                                                  year if it is not the current year;
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1221
                                                  time otherwise
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1222
        %(weekDay)      - day in week (1->monday, 2->tuesday, ... ,7->sunday)
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1223
20200
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1224
        %(dayName)      - full day name
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1225
        %(DayName)      - full day name, first character uppercase
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1226
        %(DAYNAME)      - full day name, all uppercase
16829
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1227
20200
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1228
        %(monthName)    - full month name
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1229
        %(MonthName)    - full month name, first character uppercase
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1230
        %(MONTHNAME)    - full month name, all uppercase
16829
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1231
20200
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1232
        %(shortDayName) - short (abbreviated) day name
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1233
        %(ShortDayName) - short (abbreviated) day name, first character uppercase
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1234
        %(SHORTDAYNAME) - short (abbreviated) day name, all uppercase
16829
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1235
20200
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1236
        %(shortMonthName) - short (abbreviated) month name
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1237
        %(ShortMonthName) - short (abbreviated) month name, first character uppercase
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1238
        %(SHORTMONTHNAME) - short (abbreviated) month name, all uppercase
16829
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1239
20200
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1240
        %(nth)          - counting day-in-month (1->'st'; 2->'nd'; 3->'rd'; 4...->'th')
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1241
        %(weekDayNth)   - counting day-in-week (1->'st'; 2->'nd'; 3->'rd'; 4...->'th')
16829
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1242
        %(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
  1243
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1244
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1245
     The ISO8601 printString are generated with:
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1246
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1247
       Year:
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1248
          YYYY (eg 1997)
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1249
                Date today printStringFormat:'%(year)'
20200
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1250
                Timestamp now printStringFormat:'%(year)'
16829
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1251
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1252
       Year and month:
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1253
          YYYY-MM (eg 1997-07)
20200
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1254
                Date today printStringFormat:'%(year)-%(month)'
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1255
                Timestamp now printStringFormat:'%(year)-%(month)'
16829
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1256
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1257
       Complete date:
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1258
          YYYY-MM-DD (eg 1997-07-16)
20200
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1259
                Date today printStringFormat:'%(year)-%(month)-%(day)'
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1260
                Timestamp now printStringFormat:'%(year)-%(month)-%(day)'
16829
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1261
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1262
       Complete date plus hours and minutes:
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1263
          YYYY-MM-DDThh:mmTZD (eg 1997-07-16T19:20+01:00)
20200
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1264
                Timestamp now printStringFormat:'%(year)-%(month)-%(day)T%h:%m%(TZD)'
16829
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1265
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1266
       Complete date plus hours, minutes and seconds:
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1267
          YYYY-MM-DDThh:mm:ssTZD (eg 1997-07-16T19:20:30+01:00)
20200
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1268
                Timestamp now printStringFormat:'%(year)-%(month)-%(day)T%h:%m:%s%(TZD)'
16829
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1269
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1270
       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
  1271
          YYYY-MM-DDThh:mm:ss.sTZD (eg 1997-07-16T19:20:30.45+01:00)
20200
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1272
                Timestamp now printStringFormat:'%(year)-%(month)-%(day)T%h:%m:%s.%(milli2)%(TZD)'
16829
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1273
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1274
    "
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1275
22626
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1276
    |time hours minutes seconds millis micros picos 
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1277
     millisZ3 picosZ9 fract012 fract s t|
16829
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1278
16926
755f4c452bf4 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16829
diff changeset
  1279
    time := self asTime.
755f4c452bf4 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16829
diff changeset
  1280
    hours := time hours.
755f4c452bf4 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16829
diff changeset
  1281
    minutes := time minutes.
755f4c452bf4 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16829
diff changeset
  1282
    seconds := time seconds.
16829
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1283
    millis := self milliseconds.
22626
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1284
    micros := self microseconds.
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1285
    picos := self picoseconds.
16829
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1286
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1287
    aDictionary at:$H put:(s := hours printString).
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1288
    aDictionary at:$h put:(s leftPaddedTo:2 with:$0).
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1289
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1290
    aDictionary at:$M put:(s := minutes printString).
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1291
    aDictionary at:$m put:(s leftPaddedTo:2 with:$0).
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1292
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1293
    aDictionary at:$S put:(s := seconds printString).
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1294
    aDictionary at:$s put:(s leftPaddedTo:2 with:$0).
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1295
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1296
    aDictionary at:$I put:(s := millis printString).
22626
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1297
    aDictionary at:#milli put:s.
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1298
    aDictionary at:$i put:(millisZ3 := s leftPaddedTo:3 with:$0).
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1299
    aDictionary at:#milli3 put:millisZ3.
16829
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1300
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1301
    aDictionary at:#milli1 put:((millis // 100) printString).
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1302
    aDictionary at:#milli2 put:((millis // 10) printStringLeftPaddedTo:2 with:$0).
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1303
22626
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1304
    aDictionary at:$J put:(s := micros printString).
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1305
    aDictionary at:#micro put:s.
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1306
    aDictionary at:$j put:(t := s leftPaddedTo:6 with:$0).
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1307
    aDictionary at:#micro6 put:t.
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1308
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1309
    picosZ9 := self picoseconds printString leftPaddedTo:9 with:$0.
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1310
    fract012 := millisZ3,picosZ9.
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1311
    fract := fract012 copyTo:(fract012 findLast:[:ch | ch ~~ $0] ifNone:12).
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1312
    aDictionary at:$F put:fract.
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1313
    aDictionary at:#fract put:fract.
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1314
16829
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1315
    aDictionary at:$t put:(seconds * minutes) printString.
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1316
    aDictionary at:$T put:(seconds * minutes * hours) printString.
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1317
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1318
    "
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1319
      |dict|
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1320
      dict := Dictionary new.
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1321
      Timestamp now addBasicPrintBindingsTo:dict language:#en.
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1322
      dict inspect
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1323
    "
22626
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1324
    "
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1325
      Timestamp now printStringFormat:'%(milli)'        -- millis only  
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1326
      Timestamp now printStringFormat:'%(milli3)'       -- millis padded  
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1327
      Timestamp now printStringFormat:'%(micro6)'       -- micros padded  
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1328
      Timestamp now printStringFormat:'%(fract)'        -- fraction part - as needed
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1329
      Timestamp nowWithMicroseconds printStringFormat:'%(fract)'        -- fraction part - as needed
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1330
    "
16829
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1331
!
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1332
4844
6938f0df31f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4841
diff changeset
  1333
addPrintBindingsTo:aDictionary
16829
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1334
    <resource: #obsolete>
8111
67347b7e3e69 print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents: 7672
diff changeset
  1335
16829
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1336
    self obsoleteMethodWarning:'use #addPrintBindingsTo:language:'.
8111
67347b7e3e69 print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents: 7672
diff changeset
  1337
    self addPrintBindingsTo:aDictionary language:nil
67347b7e3e69 print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents: 7672
diff changeset
  1338
!
67347b7e3e69 print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents: 7672
diff changeset
  1339
67347b7e3e69 print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents: 7672
diff changeset
  1340
addPrintBindingsTo:aDictionary language:languageOrNil
67347b7e3e69 print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents: 7672
diff changeset
  1341
    "private print support: add bindings for printing to aDictionary.
13175
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1342
     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
  1343
11772
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1344
     bindings:
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1345
        %h      hours, 00..23 (i.e. european)  0-padded to length 2
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1346
        %u      hours, 00..12 (i.e. us)        0-padded to length 2
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1347
        %m      minutes, 00..59                0-padded to length 2
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1348
        %s      seconds, 00..59                0-padded to length 2
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1349
        %i      milliseconds, 000..999         0-padded to length 3
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1350
        %a      am/pm
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1351
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1352
     Timestamp only:
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1353
        %(day)   day, 00..31                    0-padded to length 2
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1354
        %(month) month, 00..12                  0-padded to length 2
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1355
        %(year)  year, 4 digits                 0-padded to length 4
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1356
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1357
     special:
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1358
        %H      24-hours - unpadded
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1359
        %U      12-hours - unpadded
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1360
        %M      minutes - unpadded
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1361
        %S      seconds - unpadded
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1362
        %I      milliseconds, unpadded
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1363
        %A      AM/PM   - uppercase
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1364
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1365
        %t      seconds within hour  (unpadded)
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1366
        %T      seconds from midNight  (unpadded)
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1367
20200
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1368
        %(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
  1369
20200
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1370
        %(milli1) milliseconds, truncated to 1/10th of a second 0..9
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1371
        %(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
  1372
        %(milli3) milliseconds, same as %i for convenience
11772
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1373
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1374
     Timestamp only:
20200
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1375
        %(Day)         - day - unpadded
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1376
        %(Month)       - month - unpadded
13175
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1377
        %(yearOrTime)  - year or time 5 digits    as in unix-ls:
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1378
                                                  year if it is not the current year;
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1379
                                                  time otherwise
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1380
        %(weekDay)      - day in week (1->monday, 2->tuesday, ... ,7->sunday)
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1381
20200
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1382
        %(dayName)      - full day name
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1383
        %(DayName)      - full day name, first character uppercase
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1384
        %(DAYNAME)      - full day name, all uppercase
13175
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1385
20200
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1386
        %(monthName)    - full month name
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1387
        %(MonthName)    - full month name, first character uppercase
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1388
        %(MONTHNAME)    - full month name, all uppercase
13175
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1389
20200
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1390
        %(shortDayName) - short (abbreviated) day name
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1391
        %(ShortDayName) - short (abbreviated) day name, first character uppercase
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1392
        %(SHORTDAYNAME) - short (abbreviated) day name, all uppercase
13175
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1393
20200
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1394
        %(shortMonthName) - short (abbreviated) month name
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1395
        %(ShortMonthName) - short (abbreviated) month name, first character uppercase
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1396
        %(SHORTMONTHNAME) - short (abbreviated) month name, all uppercase
13175
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1397
20200
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1398
        %(nth)          - counting day-in-month (1->'st'; 2->'nd'; 3->'rd'; 4...->'th')
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1399
        %(weekDayNth)   - counting day-in-week (1->'st'; 2->'nd'; 3->'rd'; 4...->'th')
13175
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1400
        %(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
  1401
20200
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1402
        %(yearRoman)    - year, in roman letters
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1403
        %(monthRoman)   - month, in roman letters
17195
8c13747ba36d class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 17140
diff changeset
  1404
11772
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1405
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1406
     The ISO8601 printString are generated with:
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1407
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1408
       Year:
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1409
          YYYY (eg 1997)
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1410
                Date today printStringFormat:'%(year)'
20200
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1411
                Timestamp now printStringFormat:'%(year)'
11772
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1412
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1413
       Year and month:
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1414
          YYYY-MM (eg 1997-07)
20200
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1415
                Date today printStringFormat:'%(year)-%(month)'
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1416
                Timestamp now printStringFormat:'%(year)-%(month)'
11772
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1417
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1418
       Complete date:
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1419
          YYYY-MM-DD (eg 1997-07-16)
20200
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1420
                Date today printStringFormat:'%(year)-%(month)-%(day)'
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1421
                Timestamp now printStringFormat:'%(year)-%(month)-%(day)'
11772
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1422
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1423
       Complete date plus hours and minutes:
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1424
          YYYY-MM-DDThh:mmTZD (eg 1997-07-16T19:20+01:00)
20200
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1425
                Timestamp now printStringFormat:'%(year)-%(month)-%(day)T%h:%m%(TZD)'
11772
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1426
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1427
       Complete date plus hours, minutes and seconds:
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1428
          YYYY-MM-DDThh:mm:ssTZD (eg 1997-07-16T19:20:30+01:00)
20200
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1429
                Timestamp now printStringFormat:'%(year)-%(month)-%(day)T%h:%m:%s%(TZD)'
11772
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1430
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1431
       Complete date plus hours, minutes, seconds and a decimal fraction of a second
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1432
          YYYY-MM-DDThh:mm:ss.sTZD (eg 1997-07-16T19:20:30.45+01:00)
20200
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1433
                Timestamp now printStringFormat:'%(year)-%(month)-%(day)T%h:%m:%s.%(milli2)%(TZD)'
11772
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1434
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1435
    "
4844
6938f0df31f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4841
diff changeset
  1436
16829
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1437
    |usHours ampm s zone tzDelta|
4844
6938f0df31f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4841
diff changeset
  1438
16829
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1439
    self addBasicPrintBindingsTo:aDictionary language:languageOrNil.
5968
4832ed93f0b4 preps for timeZone
Claus Gittinger <cg@exept.de>
parents: 5964
diff changeset
  1440
    zone := self timeZoneName.
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
  1441
    tzDelta := self timeZoneDeltaInMinutes.
4844
6938f0df31f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4841
diff changeset
  1442
6419
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
  1443
    ampm := self meridianAbbreviation.
16829
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1444
    usHours := self hour12 printString.
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1445
    aDictionary at:$U put:usHours.
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1446
    aDictionary at:$u put:(usHours leftPaddedTo:2 with:$0).
14493
0a3c9081d40a changed: #addPrintBindingsTo:language:
Claus Gittinger <cg@exept.de>
parents: 13701
diff changeset
  1447
0a3c9081d40a changed: #addPrintBindingsTo:language:
Claus Gittinger <cg@exept.de>
parents: 13701
diff changeset
  1448
12662
a19b835e49a0 changed: #addPrintBindingsTo:language:
sr
parents: 12660
diff changeset
  1449
    aDictionary at:$a put:ampm.
a19b835e49a0 changed: #addPrintBindingsTo:language:
sr
parents: 12660
diff changeset
  1450
    aDictionary at:$A put:ampm asUppercase.
a19b835e49a0 changed: #addPrintBindingsTo:language:
sr
parents: 12660
diff changeset
  1451
    aDictionary at:$z put:zone.
a19b835e49a0 changed: #addPrintBindingsTo:language:
sr
parents: 12660
diff changeset
  1452
    aDictionary at:$Z put:zone asUppercase.
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
  1453
9432
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
  1454
    tzDelta == 0 ifTrue:[
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
  1455
        s := 'Z'.
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
  1456
    ] ifFalse:[
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
  1457
        s := tzDelta < 0 ifTrue:[ '-' ] ifFalse:[ '+' ].
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
  1458
        tzDelta := tzDelta abs.
20200
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1459
        s := s  , ((tzDelta // 60) printStringLeftPaddedTo:2 with:$0),
9432
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
  1460
            ':' , ((tzDelta \\ 60) printStringLeftPaddedTo:2 with:$0).
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
  1461
    ].
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
  1462
    aDictionary at:#TZD put:s
13082
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1463
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1464
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1465
    "
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1466
      |dict|
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1467
      dict := Dictionary new.
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1468
      Timestamp now addPrintBindingsTo:dict language:#en.
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1469
      dict inspect
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1470
    "
4844
6938f0df31f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4841
diff changeset
  1471
!
6938f0df31f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4841
diff changeset
  1472
4649
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1473
printOn:aStream format:aFormatString
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1474
    "print using a format string;
13175
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1475
     See #addPrintBindingsTo:language: for allowed format strings"
7327
ab17eb5f11a6 printFormat
Claus Gittinger <cg@exept.de>
parents: 7294
diff changeset
  1476
13175
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1477
    self printOn:aStream format:aFormatString language:nil.
10907
8b98ba82a46f Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents: 10770
diff changeset
  1478
8b98ba82a46f Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents: 10770
diff changeset
  1479
    "
8b98ba82a46f Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents: 10770
diff changeset
  1480
     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
  1481
     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
  1482
     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
  1483
     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
  1484
     Time now printOn:Transcript format:'%h:%m'      . Transcript cr. 
8b98ba82a46f Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents: 10770
diff changeset
  1485
     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
  1486
     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
  1487
    "
8b98ba82a46f Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents: 10770
diff changeset
  1488
8b98ba82a46f Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents: 10770
diff changeset
  1489
    "Modified: 22.2.1996 / 16:58:30 / cg"
8b98ba82a46f Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents: 10770
diff changeset
  1490
!
8b98ba82a46f Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents: 10770
diff changeset
  1491
13082
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1492
printOn:aStream format:aFormatString language:languageString
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1493
    "print using a format string;
13175
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1494
     See #addPrintBindingsTo:language: for allowed format strings"
13082
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1495
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1496
    |dict|
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1497
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1498
    dict := IdentityDictionary new.
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1499
    self addPrintBindingsTo:dict language:languageString.
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1500
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1501
    aFormatString expandPlaceholdersWith:dict on:aStream
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1502
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1503
    "
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1504
     Timestamp now printOn:Transcript format:'%h:%m:%s'   . Transcript cr.      
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1505
     Time now printOn:Transcript format:'%h:%m:%s'   . Transcript cr.      
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1506
     Time now printOn:Transcript format:'%H:%m:%s'   . Transcript cr.      
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1507
     Time now printOn:Transcript format:'%u:%m:%s %a'. Transcript cr.   
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1508
     Time now printOn:Transcript format:'%h:%m'      . Transcript cr. 
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1509
     Time now printOn:Transcript format:'%H:%m %A'   . Transcript cr.
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1510
     Time now printOn:Transcript format:'minutes:%M seconds:%S'. Transcript cr.
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1511
    "
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1512
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1513
    "Modified: 22.2.1996 / 16:58:30 / cg"
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1514
!
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1515
10907
8b98ba82a46f Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents: 10770
diff changeset
  1516
printStringFormat:aFormatString
13175
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1517
    "print using a format string.
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1518
     See #addPrintBindingsTo:language: for allowed format strings"
10907
8b98ba82a46f Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents: 10770
diff changeset
  1519
13175
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1520
    ^ self printStringFormat:aFormatString language:nil.
4649
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1521
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1522
    "
17400
2aad82c1d66c class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 17195
diff changeset
  1523
     Timestamp now printStringFormat:'%U:%m:%s %a'        
2aad82c1d66c class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 17195
diff changeset
  1524
     Timestamp now printStringFormat:'%u:%m:%s %a'        
4649
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1525
     Time now printStringFormat:'%U:%m:%s %a'   
17400
2aad82c1d66c class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 17195
diff changeset
  1526
     Time now printStringFormat:'%u:%m:%s %a'   
4649
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1527
4844
6938f0df31f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4841
diff changeset
  1528
     Time now printStringFormat:'%h:%m:%s'      
4649
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1529
     Time now printStringFormat:'%H:%m:%s'      
4844
6938f0df31f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4841
diff changeset
  1530
     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
  1531
     Timestamp now printStringFormat:'%H:%m:%s.%i'   
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
  1532
     Timestamp now printStringFormat:'%H:%m:%s.%(milli1)'   
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
  1533
     Timestamp now printStringFormat:'%H:%m:%s.%(milli2)'     
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
  1534
     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
  1535
     Timestamp now printStringFormat:'%(day)-%(monthName)-%(year) :%m:%s'       
4649
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1536
     Time now printStringFormat:'%u:%m:%s %a'   
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1537
     Time now printStringFormat:'%h:%m'         
4844
6938f0df31f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4841
diff changeset
  1538
     Time now printStringFormat:'%h:%m'         
4649
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1539
     Time now printStringFormat:'%H:%m %A'     
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1540
     Time now printStringFormat:'%m minutes after %U %a'     
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1541
     Time now printStringFormat:'%t seconds after %U %a'     
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1542
     Time now printStringFormat:'%T seconds from midNight'     
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1543
    "
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1544
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1545
    "Modified: 22.2.1996 / 16:58:30 / cg"
13082
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1546
!
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1547
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1548
printStringFormat:aFormatString language:languageString
13175
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1549
    "print using a format string.
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1550
     See #addPrintBindingsTo:language: for allowed format strings"
13082
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1551
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1552
    |s|
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1553
16829
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1554
    s := CharacterWriteStream on:(String new:20).
13082
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1555
    self printOn:s format:aFormatString language:languageString.
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1556
    ^ s contents.
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1557
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1558
    "
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1559
     Timestamp now printStringFormat:'%U:%m:%s %a  
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1560
     Time now printStringFormat:'%U:%m:%s %a'   
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1561
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1562
     Time now printStringFormat:'%h:%m:%s'      
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1563
     Time now printStringFormat:'%H:%m:%s'      
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1564
     Time now printStringFormat:'%H:%m:%s.%i'           
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1565
     Timestamp now printStringFormat:'%H:%m:%s.%i'   
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1566
     Timestamp now printStringFormat:'%H:%m:%s.%(milli1)'   
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1567
     Timestamp now printStringFormat:'%H:%m:%s.%(milli2)'     
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1568
     Timestamp now printStringFormat:'%(day)-%(month)-%(year) :%m:%s'       
13175
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1569
     Timestamp now printStringFormat:'%(day)-%(monthName)-%(year) :%m:%s' language:#en      
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1570
     Timestamp now printStringFormat:'%(day)-%(monthName)-%(year) :%m:%s' language:#de      
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1571
     Timestamp now printStringFormat:'%(day)-%(monthName)-%(year) :%m:%s' language:#fr      
13082
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1572
     Time now printStringFormat:'%u:%m:%s %a'   
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1573
     Time now printStringFormat:'%h:%m'         
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1574
     Time now printStringFormat:'%h:%m'         
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1575
     Time now printStringFormat:'%H:%m %A'     
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1576
     Time now printStringFormat:'%m minutes after %U %a'     
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1577
     Time now printStringFormat:'%t seconds after %U %a'     
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1578
     Time now printStringFormat:'%T seconds from midNight'     
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1579
    "
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1580
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1581
    "Modified: 22.2.1996 / 16:58:30 / cg"
4649
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1582
! !
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1583
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1584
!AbstractTime methodsFor:'private'!
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
  1585
1500
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1586
fromOSTime:osTime
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1587
    "set my time, from operatingSystems time parts"
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
  1588
1500
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1589
    ^ self subclassResponsibility
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1590
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1591
    "Modified: 1.7.1996 / 15:09:44 / cg"
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
  1592
!
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
  1593
22618
96964b12a929 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22283
diff changeset
  1594
fromOSTimeWithMilliseconds:anUninterpretedOSTime
96964b12a929 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22283
diff changeset
  1595
    "strictly private: set the milliseconds from an OS time (since the epoch)"
96964b12a929 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22283
diff changeset
  1596
96964b12a929 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22283
diff changeset
  1597
    self subclassResponsibility
96964b12a929 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22283
diff changeset
  1598
!
96964b12a929 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22283
diff changeset
  1599
22626
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1600
fromOSTimeWithMilliseconds:anUninterpretedOSTime picoseconds:picos
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1601
    "strictly private: set the milliseconds from an OS time (since the epoch) plus picoSeconds"
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1602
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1603
    self subclassResponsibility
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1604
!
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1605
1500
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1606
getMilliseconds
8200
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
  1607
    "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
  1608
     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
  1609
     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
  1610
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1611
    ^ self subclassResponsibility
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1612
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1613
    "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
  1614
!
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1615
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1616
getSeconds
22283
3edefecbb6b6 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22036
diff changeset
  1617
    "get the (truncated) seconds since some point of time in the past.
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1618
     Since I am abstract (not knowing how the time is actually
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1619
     represented), this must be done by a concrete class."
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
  1620
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1621
    ^ self subclassResponsibility
22283
3edefecbb6b6 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22036
diff changeset
  1622
3edefecbb6b6 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22036
diff changeset
  1623
    "Modified (comment): / 21-09-2017 / 18:50:30 / cg"
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1624
!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1625
1500
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1626
setMilliseconds:millis
8200
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
  1627
    "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
  1628
     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
  1629
     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
  1630
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1631
    ^ self subclassResponsibility
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1632
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1633
    "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
  1634
!
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1635
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1636
setSeconds:secs
8200
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
  1637
    "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
  1638
     Since I am abstract (not knowing how the time is actually
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1639
     represented), this must be done by a concrete class."
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1640
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1641
    ^ self subclassResponsibility
17015
f7c4867a3633 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16982
diff changeset
  1642
!
f7c4867a3633 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16982
diff changeset
  1643
f7c4867a3633 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16982
diff changeset
  1644
speciesNew
f7c4867a3633 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16982
diff changeset
  1645
    ^ self species basicNew
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
  1646
! !
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
  1647
2310
2cb1366e0eb3 Correct name: #secondDay --> #secondInDay.
Stefan Vogel <sv@exept.de>
parents: 1500
diff changeset
  1648
!AbstractTime class methodsFor:'documentation'!
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
  1649
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1650
version
18918
ea95a7e73213 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18454
diff changeset
  1651
    ^ '$Header$'
12660
518ee2523071 changed: #addPrintBindingsTo:language:
sr
parents: 12002
diff changeset
  1652
!
518ee2523071 changed: #addPrintBindingsTo:language:
sr
parents: 12002
diff changeset
  1653
518ee2523071 changed: #addPrintBindingsTo:language:
sr
parents: 12002
diff changeset
  1654
version_CVS
18918
ea95a7e73213 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18454
diff changeset
  1655
    ^ '$Header$'
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
  1656
! !
15684
4c4bc53e32c8 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 14494
diff changeset
  1657