AbstractTime.st
author Claus Gittinger <cg@exept.de>
Wed, 10 Apr 2019 06:08:33 +0200
changeset 24050 f39b5494bc52
parent 23602 fcf3d6f2f944
child 24117 c1a02a758d28
permissions -rw-r--r--
*** empty log message ***
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
22826
ec2526db594c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22632
diff changeset
     1
"{ Encoding: utf8 }"
ec2526db594c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22632
diff changeset
     2
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
     3
"
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
     4
 COPYRIGHT (c) 1995 by Claus Gittinger
7010
13fcdfdc95b1 add methods for squeak compatibility
penk
parents: 7007
diff changeset
     5
              All Rights Reserved
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
     6
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
     7
 This software is furnished under a license and may be used
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
     8
 only in accordance with the terms of that license and with the
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
     9
 inclusion of the above copyright notice.   This software may not
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
    10
 be provided or otherwise made available to, or used by, any
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
    11
 other person.  No title to or ownership of the software is
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
    12
 hereby transferred.
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
    13
"
5548
eead51e4752e added #weekInYear query
Claus Gittinger <cg@exept.de>
parents: 5191
diff changeset
    14
"{ Package: 'stx:libbasic' }"
eead51e4752e added #weekInYear query
Claus Gittinger <cg@exept.de>
parents: 5191
diff changeset
    15
17400
2aad82c1d66c class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 17195
diff changeset
    16
"{ NameSpace: Smalltalk }"
2aad82c1d66c class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 17195
diff changeset
    17
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
    18
Magnitude subclass:#AbstractTime
7258
9ccdbee7d1ad method category rename
Claus Gittinger <cg@exept.de>
parents: 7010
diff changeset
    19
	instanceVariableNames:''
9ccdbee7d1ad method category rename
Claus Gittinger <cg@exept.de>
parents: 7010
diff changeset
    20
	classVariableNames:''
9ccdbee7d1ad method category rename
Claus Gittinger <cg@exept.de>
parents: 7010
diff changeset
    21
	poolDictionaries:''
7672
46f206594db3 Category change
Stefan Vogel <sv@exept.de>
parents: 7327
diff changeset
    22
	category:'Magnitude-Time'
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
    23
!
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
    24
2310
2cb1366e0eb3 Correct name: #secondDay --> #secondInDay.
Stefan Vogel <sv@exept.de>
parents: 1500
diff changeset
    25
!AbstractTime class methodsFor:'documentation'!
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
    26
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
    27
copyright
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
    28
"
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
    29
 COPYRIGHT (c) 1995 by Claus Gittinger
7010
13fcdfdc95b1 add methods for squeak compatibility
penk
parents: 7007
diff changeset
    30
              All Rights Reserved
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
    31
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
    32
 This software is furnished under a license and may be used
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
    33
 only in accordance with the terms of that license and with the
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
    34
 inclusion of the above copyright notice.   This software may not
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
    35
 be provided or otherwise made available to, or used by, any
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
    36
 other person.  No title to or ownership of the software is
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
    37
 hereby transferred.
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
    38
"
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
    39
!
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
    40
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
    41
documentation
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
    42
"
1500
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
    43
    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
    44
    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
    45
    There are no instances of this class in the system.
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
    46
    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
    47
1295
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 1282
diff changeset
    48
    [author:]
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 1282
diff changeset
    49
        Claus Gittinger
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 1282
diff changeset
    50
1282
3f5eda57c516 commentary
Claus Gittinger <cg@exept.de>
parents: 1227
diff changeset
    51
    [See also:]
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
    52
        Time Date Timestamp
1282
3f5eda57c516 commentary
Claus Gittinger <cg@exept.de>
parents: 1227
diff changeset
    53
        Delay ProcessorScheduler
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
    54
"
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    55
!
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    56
21325
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
    57
iso8601FormatDocumentation
6172
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
  Abstract
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    60
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    61
    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
    62
    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
    63
    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
    64
    most requirements. 
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    65
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    66
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    67
  Formats
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    68
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    69
    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
    70
    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
    71
    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
    72
    of comparing two dates with different precisions.
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    73
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    74
    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
    75
    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
    76
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    77
       Year:
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    78
          YYYY (eg 1997)
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    79
       Year and month:
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    80
          YYYY-MM (eg 1997-07)
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    81
       Complete date:
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    82
          YYYY-MM-DD (eg 1997-07-16)
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    83
       Complete date plus hours and minutes:
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    84
          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
    85
       Complete date plus hours, minutes and seconds:
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    86
          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
    87
       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
    88
    second
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    89
          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
    90
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    91
    where:
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    92
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    93
         YYYY = four-digit year
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    94
         MM   = two-digit month (01=January, etc.)
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
    95
         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
    96
         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
    97
         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
    98
         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
    99
         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
   100
         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
   101
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   102
    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
   103
    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
   104
    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
   105
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   106
    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
   107
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   108
       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
   109
       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
   110
         '+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
   111
         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
   112
         'mm' minutes behind UTC. 
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
    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
   115
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   116
  The ISO8601 printString are generated with:
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   117
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   118
       Year:
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   119
          YYYY (eg 1997)
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   120
                Date today printStringFormat:'%(year)'
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   121
                Timestamp now printStringFormat:'%(year)'  
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   122
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   123
       Year and month:
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   124
          YYYY-MM (eg 1997-07)
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   125
                Date today printStringFormat:'%(year)-%(month)'  
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   126
                Timestamp now printStringFormat:'%(year)-%(month)'  
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   127
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   128
       Complete date:
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   129
          YYYY-MM-DD (eg 1997-07-16)
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   130
                Date today printStringFormat:'%(year)-%(month)-%(day)'    
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   131
                Timestamp now printStringFormat:'%(year)-%(month)-%(day)'  
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   132
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   133
       Complete date plus hours and minutes:
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   134
          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
   135
                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
   136
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   137
       Complete date plus hours, minutes and seconds:
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   138
          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
   139
                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
   140
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   141
       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
   142
          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
   143
                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
   144
"
21325
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   145
!
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
printFormatDocumentation
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   148
"
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   149
     bindings:
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   150
        %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
   151
        %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
   152
        %m      minutes, 00..59                0-padded to length 2
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   153
        %s      seconds, 00..59                0-padded to length 2
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   154
        %i      milliseconds, 000..999         0-padded to length 3
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   155
        %a      am/pm
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   156
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   157
     Timestamp only:
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   158
        %(day)   day, 00..31                    0-padded to length 2
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   159
        %(month) month, 00..12                  0-padded to length 2
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   160
        %(year)  year, 4 digits                 0-padded to length 4
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   161
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   162
     special:
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   163
        %H      24-hours - unpadded
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   164
        %U      12-hours - unpadded
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   165
        %M      minutes - unpadded
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   166
        %S      seconds - unpadded
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   167
        %I      milliseconds, unpadded
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   168
        %A      AM/PM   - uppercase
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   169
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   170
        %t      seconds within hour  (unpadded)
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   171
        %T      seconds from midNight  (unpadded)
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
        %(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
   174
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   175
        %(milli1) milliseconds, truncated to 1/10th of a second 0..9
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   176
        %(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
   177
        %(milli3) milliseconds, same as %i for convenience
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   178
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   179
     Timestamp only:
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   180
        %(Day)         - day - unpadded
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   181
        %(Month)       - month - unpadded
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   182
        %(yearOrTime)  - year or time 5 digits    as in unix-ls:
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   183
                                                  year if it is not the current year;
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   184
                                                  time otherwise
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   185
        %(weekDay)      - day in week (1->monday, 2->tuesday, ... ,7->sunday)
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   186
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   187
        %(dayName)      - full day name
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   188
        %(DayName)      - full day name, first character uppercase
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   189
        %(DAYNAME)      - full day name, all uppercase
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   190
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   191
        %(monthName)    - full month name
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   192
        %(MonthName)    - full month name, first character uppercase
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   193
        %(MONTHNAME)    - full month name, all uppercase
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   194
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   195
        %(shortDayName) - short (abbreviated) day name
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   196
        %(ShortDayName) - short (abbreviated) day name, first character uppercase
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   197
        %(SHORTDAYNAME) - short (abbreviated) day name, all uppercase
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   198
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   199
        %(shortMonthName) - short (abbreviated) month name
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   200
        %(ShortMonthName) - short (abbreviated) month name, first character uppercase
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   201
        %(SHORTMONTHNAME) - short (abbreviated) month name, all uppercase
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   202
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   203
        %(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
   204
        %(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
   205
        %(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
   206
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   207
        %(yearRoman)    - year, in roman letters
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   208
        %(monthRoman)   - month, in roman letters
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   209
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   210
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   211
     The ISO8601 printString are documented in iso8601FormatDocumentation:
d722454f36b8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20789
diff changeset
   212
"
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
   213
! !
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
   214
2310
2cb1366e0eb3 Correct name: #secondDay --> #secondInDay.
Stefan Vogel <sv@exept.de>
parents: 1500
diff changeset
   215
!AbstractTime class methodsFor:'instance creation'!
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
   216
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   217
dateAndTimeNow
1227
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   218
    "return an array filled with the current date and time.
16982
c37260d6ff78 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16941
diff changeset
   219
     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
   220
     See also: Date today / Time now / Timestamp now."
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
   221
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   222
    ^ Array with:(Date today) with:(Time now)
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
   223
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
   224
    "
16982
c37260d6ff78 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16941
diff changeset
   225
     Time dateAndTimeNow       
c37260d6ff78 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16941
diff changeset
   226
     Date dateAndTimeNow       
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
   227
    "
1227
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   228
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   229
    "Modified: 19.4.1996 / 15:23:37 / cg"
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   230
!
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
   231
9432
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
   232
epoch
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
   233
    "answer the time when we start counting"
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
    ^ self new setSeconds:0
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
   236
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
   237
    "
16982
c37260d6ff78 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16941
diff changeset
   238
     Timestamp epoch
c37260d6ff78 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16941
diff changeset
   239
     Time epoch     
9432
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
   240
    "
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
   241
!
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
   242
1227
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   243
now
19654
f07bf67efc5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19398
diff changeset
   244
    "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
   245
     Timestamps will redefine this to always return millisecond precision."
1227
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   246
1500
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
   247
    ^ self basicNew fromOSTime:(OperatingSystem getOSTime)
1227
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   248
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   249
    "
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   250
     Timestamp now   
1227
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   251
     Time now   
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   252
    "
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   253
1500
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
   254
    "Modified: 1.7.1996 / 15:20:10 / cg"
13233
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
   255
!
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
   256
22626
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   257
nowWithMicroseconds
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   258
    "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
   259
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   260
    |osTime millis micros|
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   261
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   262
    osTime := OperatingSystem getOSTimeWithMicros.
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   263
    millis := osTime at:1.
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   264
    micros := osTime at:2.
22836
1c878b36a068 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22826
diff changeset
   265
    ^ self basicNew fromOSTimeWithMilliseconds:millis additionalPicoseconds:(micros*(1000*1000)).
22626
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   266
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   267
    "
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   268
     Timestamp now   
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   269
     Time now
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   270
     Timestamp nowWithMilliseconds
22836
1c878b36a068 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22826
diff changeset
   271
     Timestamp nowWithMicroseconds
22626
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
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   274
    "Modified: 1.7.1996 / 15:20:10 / cg"
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   275
!
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   276
16941
78358165ed6b class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16934
diff changeset
   277
nowWithMilliseconds
22626
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   278
    "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
   279
78358165ed6b class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16934
diff changeset
   280
    ^ self basicNew fromOSTimeWithMilliseconds:(OperatingSystem getOSTime)
78358165ed6b class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16934
diff changeset
   281
78358165ed6b class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16934
diff changeset
   282
    "
22626
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   283
     Time now
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   284
     Time nowWithMilliseconds 
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   285
16941
78358165ed6b class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16934
diff changeset
   286
     Timestamp now   
22626
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   287
     Timestamp nowWithMilliseconds
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   288
     Timestamp nowWithMicroseconds
16941
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
78358165ed6b class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16934
diff changeset
   291
    "Modified: 1.7.1996 / 15:20:10 / cg"
78358165ed6b class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16934
diff changeset
   292
!
78358165ed6b class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16934
diff changeset
   293
13233
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
   294
utcNow
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
   295
    "return an instance of myself representing this momentin the UTC timezone."
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
   296
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
   297
    ^ self subclassResponsibility
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
   298
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
   299
    "
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
   300
     Timestamp utcNow   
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
   301
     Timestamp utcNow
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
   302
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
   303
     Time now   
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
   304
     Time utcNow   
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
   305
    "
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
   306
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
   307
    "Modified: 1.7.1996 / 15:20:10 / cg"
1227
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   308
! !
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   309
7294
c4e6d095a150 category changes
Claus Gittinger <cg@exept.de>
parents: 7261
diff changeset
   310
!AbstractTime class methodsFor:'Compatibility-Squeak'!
7007
9af8cc2f82a4 totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents: 6888
diff changeset
   311
9432
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
   312
dateAndTimeFromSeconds:secondCount
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
   313
    "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
   314
9429
173bcd493d7c Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents: 8586
diff changeset
   315
    |timestamp|
173bcd493d7c Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents: 8586
diff changeset
   316
173bcd493d7c Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents: 8586
diff changeset
   317
"   
173bcd493d7c Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents: 8586
diff changeset
   318
    secondsBetween1901and1970 := 
9432
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
   319
        (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
   320
        *  (24 * 60 * 60)
173bcd493d7c Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents: 8586
diff changeset
   321
"
173bcd493d7c Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents: 8586
diff changeset
   322
9432
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
   323
    "stc cannot make large integers"
9449
6ba774be6aa1 stc can compile large integers!
Stefan Vogel <sv@exept.de>
parents: 9432
diff changeset
   324
    timestamp := Timestamp fromSeconds:secondCount - 2177452800.
7007
9af8cc2f82a4 totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents: 6888
diff changeset
   325
    ^ Array
9429
173bcd493d7c Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents: 8586
diff changeset
   326
        with: (timestamp asDate)
173bcd493d7c Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents: 8586
diff changeset
   327
        with: (timestamp asTime)
1227
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   328
7007
9af8cc2f82a4 totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents: 6888
diff changeset
   329
    "
9429
173bcd493d7c Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents: 8586
diff changeset
   330
     Timestamp dateAndTimeFromSeconds: (Time primSecondsClock) 
7007
9af8cc2f82a4 totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents: 6888
diff changeset
   331
     Time dateAndTimeFromSeconds: (Time totalSeconds) 
9af8cc2f82a4 totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents: 6888
diff changeset
   332
     Date dateAndTimeFromSeconds: (Time totalSeconds)
9af8cc2f82a4 totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents: 6888
diff changeset
   333
    "
9af8cc2f82a4 totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents: 6888
diff changeset
   334
!
9af8cc2f82a4 totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents: 6888
diff changeset
   335
11528
a617f1faef7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11518
diff changeset
   336
milliseconds:msTime1 since:msTime2
a617f1faef7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11518
diff changeset
   337
    "return the number of milliseconds between two
a617f1faef7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11518
diff changeset
   338
     millisecond time values, compensating for roll-over.
a617f1faef7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11518
diff changeset
   339
     The same as millisecondsBetween:and: for Squeak compatibility."
a617f1faef7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11518
diff changeset
   340
a617f1faef7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11518
diff changeset
   341
    ^ OperatingSystem millisecondTimeDeltaBetween:msTime1 and:msTime2
a617f1faef7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11518
diff changeset
   342
!
a617f1faef7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11518
diff changeset
   343
9926
5bfe280953b9 *** empty log message ***
Michael Beyl <mb@exept.de>
parents: 9449
diff changeset
   344
millisecondsSince: lastTime
5bfe280953b9 *** empty log message ***
Michael Beyl <mb@exept.de>
parents: 9449
diff changeset
   345
        "Answer the elapsed time since last recorded in milliseconds.
5bfe280953b9 *** empty log message ***
Michael Beyl <mb@exept.de>
parents: 9449
diff changeset
   346
        Compensate for rollover."
5bfe280953b9 *** empty log message ***
Michael Beyl <mb@exept.de>
parents: 9449
diff changeset
   347
5bfe280953b9 *** empty log message ***
Michael Beyl <mb@exept.de>
parents: 9449
diff changeset
   348
        ^self milliseconds: self millisecondClockValue since: lastTime
5bfe280953b9 *** empty log message ***
Michael Beyl <mb@exept.de>
parents: 9449
diff changeset
   349
!
5bfe280953b9 *** empty log message ***
Michael Beyl <mb@exept.de>
parents: 9449
diff changeset
   350
7007
9af8cc2f82a4 totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents: 6888
diff changeset
   351
primSecondsClock
9429
173bcd493d7c Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents: 8586
diff changeset
   352
    "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
   353
173bcd493d7c Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents: 8586
diff changeset
   354
    ^ Timestamp now utcSecondsSince1901
1227
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   355
20200
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
   356
    "
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
   357
     Timestamp primSecondsClock
9429
173bcd493d7c Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents: 8586
diff changeset
   358
    "
1227
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   359
! !
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   360
7294
c4e6d095a150 category changes
Claus Gittinger <cg@exept.de>
parents: 7261
diff changeset
   361
!AbstractTime class methodsFor:'Compatibility-VW'!
7007
9af8cc2f82a4 totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents: 6888
diff changeset
   362
9af8cc2f82a4 totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents: 6888
diff changeset
   363
totalSeconds
9429
173bcd493d7c Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents: 8586
diff changeset
   364
    "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
   365
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   366
    ^ Timestamp now utcSecondsSince1901
7007
9af8cc2f82a4 totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents: 6888
diff changeset
   367
! !
9af8cc2f82a4 totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents: 6888
diff changeset
   368
11130
fb6ebdb8c2a1 conversion errors
Claus Gittinger <cg@exept.de>
parents: 10907
diff changeset
   369
!AbstractTime class methodsFor:'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
conversionErrorSignal
fb6ebdb8c2a1 conversion errors
Claus Gittinger <cg@exept.de>
parents: 10907
diff changeset
   372
    "return the signal used for conversion error handling"
fb6ebdb8c2a1 conversion errors
Claus Gittinger <cg@exept.de>
parents: 10907
diff changeset
   373
fb6ebdb8c2a1 conversion errors
Claus Gittinger <cg@exept.de>
parents: 10907
diff changeset
   374
    ^ TimeConversionError
fb6ebdb8c2a1 conversion errors
Claus Gittinger <cg@exept.de>
parents: 10907
diff changeset
   375
! !
fb6ebdb8c2a1 conversion errors
Claus Gittinger <cg@exept.de>
parents: 10907
diff changeset
   376
13701
46009307d8e3 added: defaultFormatString
ca
parents: 13233
diff changeset
   377
!AbstractTime class methodsFor:'format strings'!
46009307d8e3 added: defaultFormatString
ca
parents: 13233
diff changeset
   378
46009307d8e3 added: defaultFormatString
ca
parents: 13233
diff changeset
   379
defaultFormatString
46009307d8e3 added: defaultFormatString
ca
parents: 13233
diff changeset
   380
    ^ '%h:%m:%s'
46009307d8e3 added: defaultFormatString
ca
parents: 13233
diff changeset
   381
! !
46009307d8e3 added: defaultFormatString
ca
parents: 13233
diff changeset
   382
18454
79aa7d84d07f class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 17400
diff changeset
   383
7258
9ccdbee7d1ad method category rename
Claus Gittinger <cg@exept.de>
parents: 7010
diff changeset
   384
!AbstractTime class methodsFor:'private-instance creation'!
1227
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   385
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   386
fromOSTime:osTime
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   387
    "return a time, representing the time given by the operatingSystem time.
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   388
     Not meant for public use."
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   389
1500
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
   390
    ^ self basicNew fromOSTime:osTime.
418
claus
parents: 384
diff changeset
   391
1500
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
   392
    "Modified: 1.7.1996 / 15:09:54 / cg"
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
   393
!
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
   394
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   395
fromSeconds:seconds
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   396
    "return an instance that is constructed from seconds.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   397
     This method is only allowed for second values as returned by
20200
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
   398
     getSeconds, possibly adding/subtracting to that.
1227
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   399
     Never depend on any specific interpretation of the seconds,
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   400
     since it depends on how the OperatingSystem counts time
e89b39909085 commentary & category changes
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   401
     (some start at 1900, others with 1970 ...)"
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
   402
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   403
   ^ self basicNew setSeconds:seconds
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
   404
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
   405
    "
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   406
     Time fromSeconds:0             should return midnight
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   407
     Timestamp fromSeconds:0     on UNIX: returns 1st. Jan 1970
20789
4a410e6b1dff #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20200
diff changeset
   408
                                    on others: don't know
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   409
     (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
   410
        getSeconds                  on UNIX: returns 0
20200
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
   411
                                    on others: don't know
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   412
    "
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   413
1500
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
   414
    "Modified: 1.7.1996 / 13:39:30 / cg"
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
   415
! !
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
   416
2310
2cb1366e0eb3 Correct name: #secondDay --> #secondInDay.
Stefan Vogel <sv@exept.de>
parents: 1500
diff changeset
   417
!AbstractTime class methodsFor:'queries'!
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   418
18918
ea95a7e73213 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18454
diff changeset
   419
isAbstract
ea95a7e73213 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18454
diff changeset
   420
    ^ self == AbstractTime
ea95a7e73213 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18454
diff changeset
   421
!
ea95a7e73213 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18454
diff changeset
   422
15684
4c4bc53e32c8 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 14494
diff changeset
   423
microsecondClockValue
4c4bc53e32c8 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 14494
diff changeset
   424
    "return microseconds seconds of now"
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
    ^ OperatingSystem getMicrosecondTime
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
     Time microsecondClockValue
4c4bc53e32c8 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 14494
diff changeset
   430
    "
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
    "
4c4bc53e32c8 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 14494
diff changeset
   433
     |t1 t2 overhead|
4c4bc53e32c8 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 14494
diff changeset
   434
4c4bc53e32c8 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 14494
diff changeset
   435
     t1 := Time microsecondClockValue.
4c4bc53e32c8 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 14494
diff changeset
   436
     t2 := Time microsecondClockValue.
4c4bc53e32c8 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 14494
diff changeset
   437
     overhead := t2 - t1.  
4c4bc53e32c8 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 14494
diff changeset
   438
4c4bc53e32c8 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 14494
diff changeset
   439
     t1 := Time microsecondClockValue.
4c4bc53e32c8 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 14494
diff changeset
   440
     100 factorial.
4c4bc53e32c8 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 14494
diff changeset
   441
     t2 := Time microsecondClockValue.
4c4bc53e32c8 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 14494
diff changeset
   442
     t2 - t1 - overhead        
4c4bc53e32c8 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 14494
diff changeset
   443
    "
4c4bc53e32c8 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 14494
diff changeset
   444
!
4c4bc53e32c8 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 14494
diff changeset
   445
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   446
millisecondClockValue
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   447
    "return the millisecond clock - since this one overruns
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   448
     regularly, use the value only for short timing deltas.
5730
b377ec6357e7 comment
Claus Gittinger <cg@exept.de>
parents: 5573
diff changeset
   449
     Also remember that it wraps when comparing these values."
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   450
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   451
    ^ OperatingSystem getMillisecondTime.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   452
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   453
    "
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   454
     Time millisecondClockValue 
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   455
    "
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   456
!
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   457
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   458
secondClock
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   459
    "return seconds of now - for GNU-ST compatibility"
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   460
1500
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
   461
    ^ OperatingSystem getOSTime // 1000
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   462
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   463
    "
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   464
     AbstractTime secondClock    
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   465
    "
1500
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
   466
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
   467
    "Modified: 1.7.1996 / 15:20:14 / cg"
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   468
! !
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   469
18454
79aa7d84d07f class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 17400
diff changeset
   470
!AbstractTime class methodsFor:'reading'!
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
readFrom:aStringOrStream format:formatString
79aa7d84d07f class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 17400
diff changeset
   473
    "see format description in readFrom:format:language:onError:"
79aa7d84d07f class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 17400
diff changeset
   474
79aa7d84d07f class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 17400
diff changeset
   475
    ^ self 
79aa7d84d07f class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 17400
diff changeset
   476
        readFrom:aStringOrStream format:formatString language:nil 
79aa7d84d07f class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 17400
diff changeset
   477
        onError:[
19894
c03dc72fc13b #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 19654
diff changeset
   478
            self conversionErrorSignal raiseErrorString:' - Timestamp format error'
18454
79aa7d84d07f class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 17400
diff changeset
   479
        ].
79aa7d84d07f class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 17400
diff changeset
   480
!
79aa7d84d07f class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 17400
diff changeset
   481
19894
c03dc72fc13b #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 19654
diff changeset
   482
readFrom:aStringOrStream format:formatString language:languageString onError:exceptionalValue
c03dc72fc13b #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 19654
diff changeset
   483
    ^ self subclassResponsibility
c03dc72fc13b #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 19654
diff changeset
   484
!
c03dc72fc13b #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 19654
diff changeset
   485
18454
79aa7d84d07f class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 17400
diff changeset
   486
readFrom:aStringOrStream format:formatString onError:exceptionalValue
79aa7d84d07f class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 17400
diff changeset
   487
    "see format description in readFrom:format:language:onError:"
79aa7d84d07f class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 17400
diff changeset
   488
79aa7d84d07f class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 17400
diff changeset
   489
    ^ self readFrom:aStringOrStream format:formatString language:nil onError:exceptionalValue
79aa7d84d07f class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 17400
diff changeset
   490
! !
79aa7d84d07f class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 17400
diff changeset
   491
2310
2cb1366e0eb3 Correct name: #secondDay --> #secondInDay.
Stefan Vogel <sv@exept.de>
parents: 1500
diff changeset
   492
!AbstractTime class methodsFor:'timing evaluations'!
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   493
12831
97be4636cf07 added: #microsecondsToRun:
Stefan Vogel <sv@exept.de>
parents: 12662
diff changeset
   494
microsecondsToRun:aBlock
16673
38e6f4c80e3a fixed buggy copy pasta comment
az
parents: 16505
diff changeset
   495
    "evaluate the argument, aBlock; return the number of microseconds it took"
12831
97be4636cf07 added: #microsecondsToRun:
Stefan Vogel <sv@exept.de>
parents: 12662
diff changeset
   496
97be4636cf07 added: #microsecondsToRun:
Stefan Vogel <sv@exept.de>
parents: 12662
diff changeset
   497
    |startTime endTime|
97be4636cf07 added: #microsecondsToRun:
Stefan Vogel <sv@exept.de>
parents: 12662
diff changeset
   498
97be4636cf07 added: #microsecondsToRun:
Stefan Vogel <sv@exept.de>
parents: 12662
diff changeset
   499
    startTime := OperatingSystem getMicrosecondTime.
97be4636cf07 added: #microsecondsToRun:
Stefan Vogel <sv@exept.de>
parents: 12662
diff changeset
   500
    aBlock value.
97be4636cf07 added: #microsecondsToRun:
Stefan Vogel <sv@exept.de>
parents: 12662
diff changeset
   501
    endTime := OperatingSystem getMicrosecondTime.
97be4636cf07 added: #microsecondsToRun:
Stefan Vogel <sv@exept.de>
parents: 12662
diff changeset
   502
    ^ endTime - startTime
97be4636cf07 added: #microsecondsToRun:
Stefan Vogel <sv@exept.de>
parents: 12662
diff changeset
   503
97be4636cf07 added: #microsecondsToRun:
Stefan Vogel <sv@exept.de>
parents: 12662
diff changeset
   504
    "
97be4636cf07 added: #microsecondsToRun:
Stefan Vogel <sv@exept.de>
parents: 12662
diff changeset
   505
     Time microsecondsToRun:[1000 factorial]  
97be4636cf07 added: #microsecondsToRun:
Stefan Vogel <sv@exept.de>
parents: 12662
diff changeset
   506
    "
16673
38e6f4c80e3a fixed buggy copy pasta comment
az
parents: 16505
diff changeset
   507
38e6f4c80e3a fixed buggy copy pasta comment
az
parents: 16505
diff changeset
   508
    "Modified (comment): / 01-07-2014 / 15:57:13 / az"
12831
97be4636cf07 added: #microsecondsToRun:
Stefan Vogel <sv@exept.de>
parents: 12662
diff changeset
   509
!
97be4636cf07 added: #microsecondsToRun:
Stefan Vogel <sv@exept.de>
parents: 12662
diff changeset
   510
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   511
millisecondsToRun:aBlock
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   512
    "evaluate the argument, aBlock; return the number of milliseconds it took"
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   513
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   514
    |startTime endTime|
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   515
1476
02f69251f5bc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   516
    startTime := OperatingSystem getMillisecondTime.
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   517
    aBlock value.
1476
02f69251f5bc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   518
    endTime := OperatingSystem getMillisecondTime.
8586
a38e882affa5 take care of time-wrap in #millisecondsToRun:
Stefan Vogel <sv@exept.de>
parents: 8450
diff changeset
   519
    ^ self milliseconds:endTime since:startTime
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   520
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   521
    "
8586
a38e882affa5 take care of time-wrap in #millisecondsToRun:
Stefan Vogel <sv@exept.de>
parents: 8450
diff changeset
   522
     Time millisecondsToRun:[1000 factorial]  
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   523
    "
1476
02f69251f5bc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   524
02f69251f5bc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   525
    "Modified: 17.6.1996 / 16:57:37 / cg"
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   526
!
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   527
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   528
secondsToRun:aBlock
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   529
    "evaluate the argument, aBlock; return the number of seconds it took"
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   530
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   531
    |startTime endTime|
360
claus
parents: 275
diff changeset
   532
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   533
    startTime := self secondClock.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   534
    aBlock value.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   535
    endTime := self secondClock.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   536
    ^ endTime - startTime
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   537
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   538
    "
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   539
     Time secondsToRun:[1000 factorial]  
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   540
    "
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   541
! !
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   542
7261
f35fc9cee675 method category rename
Claus Gittinger <cg@exept.de>
parents: 7258
diff changeset
   543
!AbstractTime methodsFor:'Compatibility-ANSI'!
6419
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
hour12
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   546
    "return the hour (1..12)."
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
    ^ self hours - 1 \\ 12 + 1.
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   549
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   550
    "
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   551
     Time now hour12   
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   552
     Time now hour24   
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   553
     (Time hours:0 minutes:0 seconds:0) hour24   
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   554
     (Time hours:0 minutes:0 seconds:0) hour12   
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   555
     (Time hours:1 minutes:0 seconds:0) hour24   
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   556
     (Time hours:1 minutes:0 seconds:0) hour12   
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   557
     (Time hours:12 minutes:0 seconds:0) hour24 
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   558
     (Time hours:12 minutes:0 seconds:0) hour12   
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   559
     (Time hours:13 minutes:0 seconds:0) hour24 
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   560
     (Time hours:13 minutes:0 seconds:0) hour12   
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   561
     (Time hours:23 minutes:0 seconds:0) hour24 
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   562
     (Time hours:23 minutes:0 seconds:0) hour12   
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   563
     (Time hours:24 minutes:0 seconds:0) hour24 
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   564
     (Time hours:24 minutes:0 seconds:0) hour12   
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   565
    "
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   566
!
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
hour24
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   569
    "return the hour (0..23)."
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
    ^ self hours
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   572
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   573
    "
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   574
     Time now hour12   
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   575
     Time now hour24   
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   576
     (Time hours:0 minutes:0 seconds:0) hour24 
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   577
     (Time hours:0 minutes:0 seconds:0) hour12 
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   578
     (Time hours:1 minutes:0 seconds:0) hour24 
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   579
     (Time hours:1 minutes:0 seconds:0) hour12 
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   580
     (Time hours:12 minutes:0 seconds:0) hour24 
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   581
     (Time hours:12 minutes:0 seconds:0) hour12 
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   582
     (Time hours:13 minutes:0 seconds:0) hour24 
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   583
     (Time hours:13 minutes:0 seconds:0) hour12 
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   584
     (Time hours:23 minutes:0 seconds:0) hour24 
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   585
     (Time hours:23 minutes:0 seconds:0) hour12 
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   586
     (Time hours:24 minutes:0 seconds:0) hour24 
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   587
     (Time hours:24 minutes:0 seconds:0) hour12 
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   588
    "
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   589
!
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
meridianAbbreviation
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   592
    "am/pm"
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   593
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   594
    self hours // 12 == 0 ifTrue:[
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   595
        ^ 'am'.
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   596
    ] ifFalse:[
8200
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   597
        (self hours == 12 and:[self minutes == 0 and:[self seconds == 0]]) ifTrue:[
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   598
            ^ 'noon'
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   599
        ].
6419
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   600
        ^ 'pm'.
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   601
    ].
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   602
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   603
    "
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   604
     Time now meridianAbbreviation   
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   605
     (Time hours:0 minutes:0 seconds:0) meridianAbbreviation  
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   606
     (Time hours:11 minutes:59 seconds:59) meridianAbbreviation  
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   607
     (Time hours:12 minutes:0 seconds:0) meridianAbbreviation    
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   608
     (Time hours:12 minutes:0 seconds:1) meridianAbbreviation  
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   609
    "
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   610
! !
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
   611
23235
acf3d6e991aa #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23020
diff changeset
   612
!AbstractTime methodsFor:'Compatibility-ST80'!
acf3d6e991aa #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23020
diff changeset
   613
acf3d6e991aa #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23020
diff changeset
   614
hour
acf3d6e991aa #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23020
diff changeset
   615
    "return the hour (0..23).
acf3d6e991aa #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23020
diff changeset
   616
     ST-80 Timestamp compatibility 
acf3d6e991aa #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23020
diff changeset
   617
     (I'd prefer the name #hours, for Time compatibility)."
acf3d6e991aa #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23020
diff changeset
   618
acf3d6e991aa #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23020
diff changeset
   619
    ^ self hours
acf3d6e991aa #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23020
diff changeset
   620
acf3d6e991aa #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23020
diff changeset
   621
    "Created: 1.7.1996 / 15:14:50 / cg"
acf3d6e991aa #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23020
diff changeset
   622
    "Modified: 1.7.1996 / 15:15:32 / cg"
acf3d6e991aa #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23020
diff changeset
   623
!
acf3d6e991aa #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23020
diff changeset
   624
acf3d6e991aa #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23020
diff changeset
   625
minute
acf3d6e991aa #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23020
diff changeset
   626
    "return the minute (0..59).
acf3d6e991aa #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23020
diff changeset
   627
     ST-80 Timestamp compatibility 
acf3d6e991aa #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23020
diff changeset
   628
     (I'd prefer the name #minutes, for Time compatibility)."
acf3d6e991aa #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23020
diff changeset
   629
acf3d6e991aa #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23020
diff changeset
   630
    ^ self minutes
acf3d6e991aa #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23020
diff changeset
   631
acf3d6e991aa #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23020
diff changeset
   632
    "Created: 1.7.1996 / 15:14:29 / cg"
acf3d6e991aa #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23020
diff changeset
   633
    "Modified: 1.7.1996 / 15:15:37 / cg"
acf3d6e991aa #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23020
diff changeset
   634
!
acf3d6e991aa #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23020
diff changeset
   635
acf3d6e991aa #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23020
diff changeset
   636
second
acf3d6e991aa #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23020
diff changeset
   637
    "return the second (0..59).
acf3d6e991aa #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23020
diff changeset
   638
     ST-80 Timestamp compatibility 
acf3d6e991aa #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23020
diff changeset
   639
     (I'd prefer the name #seconds, for Time compatibility)."
acf3d6e991aa #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23020
diff changeset
   640
acf3d6e991aa #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23020
diff changeset
   641
    ^ self seconds
acf3d6e991aa #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23020
diff changeset
   642
acf3d6e991aa #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23020
diff changeset
   643
    "Created: 1.7.1996 / 15:14:19 / cg"
acf3d6e991aa #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23020
diff changeset
   644
    "Modified: 1.7.1996 / 15:15:49 / cg"
acf3d6e991aa #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23020
diff changeset
   645
! !
acf3d6e991aa #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23020
diff changeset
   646
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   647
!AbstractTime methodsFor:'abstract'!
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   648
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   649
hours
8200
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   650
    "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
   651
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   652
    ^ self subclassResponsibility
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
    "
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   655
     Timestamp now hours 
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   656
     Time now hours 
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   657
    "
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   658
!
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   659
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   660
milliseconds
8200
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   661
    "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
   662
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   663
    ^ self subclassResponsibility
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   664
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   665
    "
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   666
     Timestamp now milliseconds 
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   667
     Time now milliseconds 
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   668
    "
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   669
!
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   670
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   671
minutes
8200
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   672
    "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
   673
7672
46f206594db3 Category change
Stefan Vogel <sv@exept.de>
parents: 7327
diff changeset
   674
    ^ self subclassResponsibility.
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   675
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   676
    "
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   677
     Timestamp now minutes 
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   678
     Time now minutes 
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   679
    "
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   680
!
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   681
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   682
seconds
8200
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   683
    "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
   684
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   685
    ^ self subclassResponsibility
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   686
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   687
    "
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   688
     Timestamp now seconds. 
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   689
     Time now seconds 
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   690
    "
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   691
! !
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   692
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   693
!AbstractTime methodsFor:'accessing'!
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   694
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   695
hourInDay
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   696
    "return the hours (0..23)"
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   697
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   698
    ^ self hours
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   699
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   700
    "
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   701
     Timestamp now hourInDay 
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   702
     Time now hourInDay 
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   703
    "
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   704
!
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   705
22626
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   706
microseconds
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   707
    "return the microseconds within the current second (0..999999)"
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   708
22836
1c878b36a068 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22826
diff changeset
   709
    ^ (self milliseconds * 1000) + (self additionalPicoseconds // (1000*1000)).
22626
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   710
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   711
    "
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   712
     Timestamp now microseconds   
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   713
     Timestamp nowWithMicroseconds microseconds   
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   714
    "
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   715
!
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   716
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   717
minuteInDay
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   718
    "return the minutes (0..59)"
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   719
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   720
    ^ self minutes.
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   721
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   722
    "
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   723
     Timestamp now minuteInDay 
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   724
     Time now minuteInDay 
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   725
    "
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   726
!
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   727
22845
dfdd78f1f144 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22838
diff changeset
   728
nanoseconds
dfdd78f1f144 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22838
diff changeset
   729
    "return the nanoseconds within the current second (0..999999)"
dfdd78f1f144 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22838
diff changeset
   730
dfdd78f1f144 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22838
diff changeset
   731
    ^ (self milliseconds * 1000000) + (self additionalPicoseconds // (1000)).
dfdd78f1f144 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22838
diff changeset
   732
dfdd78f1f144 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22838
diff changeset
   733
    "
dfdd78f1f144 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22838
diff changeset
   734
     Timestamp now nanoseconds   
dfdd78f1f144 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22838
diff changeset
   735
     Timestamp nowWithMicroseconds nanoseconds   
dfdd78f1f144 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22838
diff changeset
   736
    "
dfdd78f1f144 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22838
diff changeset
   737
!
dfdd78f1f144 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22838
diff changeset
   738
22626
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   739
picoseconds
22836
1c878b36a068 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22826
diff changeset
   740
    "return the picoseconds within the current second (0..999999999).
1c878b36a068 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22826
diff changeset
   741
     notice: that is NOT the total number of picoseconds,
1c878b36a068 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22826
diff changeset
   742
     but the fractional part (within the second) only. 
1c878b36a068 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22826
diff changeset
   743
     Use this only for printing.
1c878b36a068 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22826
diff changeset
   744
     Here, fall back and generate something based on the milliseconds"
22626
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   745
22845
dfdd78f1f144 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22838
diff changeset
   746
    ^ (self milliseconds * 1000 * 1000 * 1000) + (self additionalPicoseconds).
22626
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   747
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   748
    "
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   749
     Timestamp now picoseconds
22836
1c878b36a068 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22826
diff changeset
   750
     Timestamp nowWithMicroseconds picoseconds
22845
dfdd78f1f144 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22838
diff changeset
   751
dfdd78f1f144 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22838
diff changeset
   752
     (TimeDuration fromPicoseconds:100) picoseconds
dfdd78f1f144 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22838
diff changeset
   753
     (TimeDuration fromPicoseconds:100000) picoseconds
dfdd78f1f144 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22838
diff changeset
   754
     (TimeDuration fromPicoseconds:100000) nanoseconds
dfdd78f1f144 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22838
diff changeset
   755
     (TimeDuration fromPicoseconds:100000000) picoseconds
dfdd78f1f144 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22838
diff changeset
   756
     (TimeDuration fromPicoseconds:100000000) nanoseconds
dfdd78f1f144 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22838
diff changeset
   757
     (TimeDuration fromPicoseconds:100000000) microseconds
dfdd78f1f144 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22838
diff changeset
   758
     (TimeDuration fromPicoseconds:100000000000) picoseconds
dfdd78f1f144 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22838
diff changeset
   759
     (TimeDuration fromPicoseconds:100000000000) nanoseconds
dfdd78f1f144 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22838
diff changeset
   760
     (TimeDuration fromPicoseconds:100000000000) microseconds
dfdd78f1f144 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22838
diff changeset
   761
     (TimeDuration fromPicoseconds:100000000000) milliseconds
22626
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   762
    "
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   763
!
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
   764
2310
2cb1366e0eb3 Correct name: #secondDay --> #secondInDay.
Stefan Vogel <sv@exept.de>
parents: 1500
diff changeset
   765
secondInDay
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   766
    "return the seconds (0..59)"
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   767
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   768
    ^ self seconds
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   769
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   770
    "
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   771
     Timestamp now secondInDay 
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   772
     Time now seconds 
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   773
    "
2310
2cb1366e0eb3 Correct name: #secondDay --> #secondInDay.
Stefan Vogel <sv@exept.de>
parents: 1500
diff changeset
   774
2cb1366e0eb3 Correct name: #secondDay --> #secondInDay.
Stefan Vogel <sv@exept.de>
parents: 1500
diff changeset
   775
    "Created: 22.10.1996 / 09:27:47 / stefan"
5548
eead51e4752e added #weekInYear query
Claus Gittinger <cg@exept.de>
parents: 5191
diff changeset
   776
!
eead51e4752e added #weekInYear query
Claus Gittinger <cg@exept.de>
parents: 5191
diff changeset
   777
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   778
timeZoneDeltaInMinutes
9432
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
   779
    "answer the number of minutes between local time and utc time.
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
   780
     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
   781
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   782
    ^ 0
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   783
!
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
   784
5968
4832ed93f0b4 preps for timeZone
Claus Gittinger <cg@exept.de>
parents: 5964
diff changeset
   785
timeZoneName
16982
c37260d6ff78 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16941
diff changeset
   786
    ^ 'UTC'
c37260d6ff78 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16941
diff changeset
   787
!
c37260d6ff78 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16941
diff changeset
   788
c37260d6ff78 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16941
diff changeset
   789
utcOffset
c37260d6ff78 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16941
diff changeset
   790
    ^ 0
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   791
! !
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   792
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   793
!AbstractTime methodsFor:'arithmetic'!
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   794
10679
b4dd3412ce74 adding timeDurations to a timeStamp (double dispatch)
sr
parents: 10485
diff changeset
   795
+ aNumberOrTimeDuration
22845
dfdd78f1f144 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22838
diff changeset
   796
    "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
   797
10679
b4dd3412ce74 adding timeDurations to a timeStamp (double dispatch)
sr
parents: 10485
diff changeset
   798
    ^ aNumberOrTimeDuration sumFromTimestamp:self.
b4dd3412ce74 adding timeDurations to a timeStamp (double dispatch)
sr
parents: 10485
diff changeset
   799
8200
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   800
    "
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   801
     Timestamp now to:(Timestamp now + 30) by:2 do:[:time|
8200
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   802
        Transcript showCR:time.
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   803
     ].
22845
dfdd78f1f144 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22838
diff changeset
   804
     Timestamp now to:(Timestamp now + 30) by:2 seconds do:[:time|
dfdd78f1f144 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22838
diff changeset
   805
        Transcript showCR:time.
dfdd78f1f144 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22838
diff changeset
   806
     ].
dfdd78f1f144 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22838
diff changeset
   807
     (Timestamp now + 30 seconds) to:(Timestamp now) by:-2 seconds do:[:time|
dfdd78f1f144 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22838
diff changeset
   808
        Transcript showCR:time.
dfdd78f1f144 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22838
diff changeset
   809
     ].
dfdd78f1f144 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22838
diff changeset
   810
     (Timestamp now + 30 seconds) to:(Timestamp now) by:-2 do:[:time|
dfdd78f1f144 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22838
diff changeset
   811
        Transcript showCR:time.
dfdd78f1f144 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22838
diff changeset
   812
     ].
8200
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   813
10679
b4dd3412ce74 adding timeDurations to a timeStamp (double dispatch)
sr
parents: 10485
diff changeset
   814
     (Timestamp now + 20)  -  Timestamp now  
b4dd3412ce74 adding timeDurations to a timeStamp (double dispatch)
sr
parents: 10485
diff changeset
   815
     (Timestamp now + 0.5)  -  Timestamp now  
b4dd3412ce74 adding timeDurations to a timeStamp (double dispatch)
sr
parents: 10485
diff changeset
   816
     (Timestamp now + (TimeDuration fromString:'1m 10s'))  -  Timestamp now  
11771
1c6251b7286d comment
Claus Gittinger <cg@exept.de>
parents: 11528
diff changeset
   817
     (Timestamp now + (10 seconds))  -  Timestamp now  
8200
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   818
    "
21427
26521b634779 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21335
diff changeset
   819
26521b634779 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21335
diff changeset
   820
    "Modified (comment): / 13-02-2017 / 19:55:04 / cg"
8200
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   821
!
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   822
22845
dfdd78f1f144 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22838
diff changeset
   823
- aTimeOrTimeDurationOrNumberOfSeconds
8244
06543e00260e comment
Claus Gittinger <cg@exept.de>
parents: 8200
diff changeset
   824
    "return the delta in seconds between 2 times or subtract a number of seconds."
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   825
22845
dfdd78f1f144 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22838
diff changeset
   826
    ^ aTimeOrTimeDurationOrNumberOfSeconds differenceFromTimestamp:self.
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   827
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   828
    "
22845
dfdd78f1f144 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22838
diff changeset
   829
     Timestamp now - 3600.                          -> 2018-05-09 15:37:57.485
dfdd78f1f144 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22838
diff changeset
   830
     Timestamp now - 3600 seconds.                  -> 2018-05-09 15:38:04.665
dfdd78f1f144 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22838
diff changeset
   831
     (Timestamp now addSeconds:10) - Timestamp now  -> 10s
dfdd78f1f144 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22838
diff changeset
   832
dfdd78f1f144 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22838
diff changeset
   833
     Time now - 3600.                               -> 03:38:23 PM
dfdd78f1f144 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22838
diff changeset
   834
     Time now - 3600 seconds.                       -> 03:38:35 PM
dfdd78f1f144 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22838
diff changeset
   835
     (Time now addSeconds:10) - Time now            -> 10s 
dfdd78f1f144 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22838
diff changeset
   836
dfdd78f1f144 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22838
diff changeset
   837
     (TimeDuration fromString:'1.5hr') - 3600.                           -> 30m 
dfdd78f1f144 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22838
diff changeset
   838
     (TimeDuration fromString:'1.5hr') - (TimeDuration fromString:'1hr') -> 30m  
8200
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
   839
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   840
     |t1 t2|
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
     t1 := Timestamp now.
16407
67eeb7ae5eb8 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16365
diff changeset
   843
     Delay waitFor:10 seconds.
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   844
     t2 := Timestamp now.
3476
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   845
     Transcript showCR:('seconds passed: ' , (t2 - t1) printString).
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   846
    "
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   847
!
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   848
6048
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   849
addDays:numberOfDays
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   850
    "return a new instance of myself, numberOfDays afterwards."
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   851
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   852
    ^ self addSeconds:(numberOfDays * (60 * 60 * 24))
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   853
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   854
    "
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   855
     |t|
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   856
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   857
     t := Timestamp now.
6048
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   858
     Transcript showCR:t.
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   859
     Transcript showCR:(t addDays:7)
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   860
    "
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   861
!
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
   862
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   863
addHours:numberOfHours
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   864
    "return a new instance of myself, numberOfHours afterwards."
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   865
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   866
    ^ self addSeconds:(numberOfHours * (60 * 60))
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   867
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   868
    "
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   869
     |t|
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   870
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   871
     t := Timestamp now.
3476
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   872
     Transcript showCR:t.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   873
     Transcript showCR:(t addHours:12).
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   874
    "
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   875
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   876
    "
3476
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   877
     |t|
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   878
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   879
     t := Time now.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   880
     Transcript showCR:t.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   881
     Transcript showCR:(t addHours:12).
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   882
    "
6043
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   883
!
3476
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   884
22945
c6f530d70280 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22925
diff changeset
   885
addMicroseconds:numberOfMicroSeconds
c6f530d70280 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22925
diff changeset
   886
    "return a new instance of myself, numberOfMicroSeconds afterwards."
c6f530d70280 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22925
diff changeset
   887
c6f530d70280 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22925
diff changeset
   888
    ^ self speciesNew 
c6f530d70280 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22925
diff changeset
   889
        setMilliseconds:(self getMilliseconds + (numberOfMicroSeconds // 1000))
c6f530d70280 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22925
diff changeset
   890
        additionalPicoseconds:(self additionalPicoseconds 
22988
46b7e5b5dc48 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 22945
diff changeset
   891
                                + ((numberOfMicroSeconds \\ 1000)*1000000) truncated)
22945
c6f530d70280 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22925
diff changeset
   892
c6f530d70280 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22925
diff changeset
   893
    "
c6f530d70280 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22925
diff changeset
   894
     |t1 t2|
c6f530d70280 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22925
diff changeset
   895
c6f530d70280 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22925
diff changeset
   896
     t1 := Timestamp now.
c6f530d70280 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22925
diff changeset
   897
     Transcript showCR:t1.
c6f530d70280 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22925
diff changeset
   898
     t2 := t1 addMicroseconds:1000.
c6f530d70280 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22925
diff changeset
   899
     Transcript showCR:t2.
c6f530d70280 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22925
diff changeset
   900
     t2 := t1 addMicroseconds:1010.
c6f530d70280 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22925
diff changeset
   901
     Transcript showCR:t2.
c6f530d70280 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22925
diff changeset
   902
     Transcript showCR:(t2 - t1).
c6f530d70280 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22925
diff changeset
   903
     self halt.
c6f530d70280 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22925
diff changeset
   904
     Transcript showCR:(t2 - t1) asMicroseconds.
c6f530d70280 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22925
diff changeset
   905
    "
c6f530d70280 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22925
diff changeset
   906
c6f530d70280 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22925
diff changeset
   907
    "
c6f530d70280 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22925
diff changeset
   908
     |t|
c6f530d70280 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22925
diff changeset
   909
c6f530d70280 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22925
diff changeset
   910
     t := Time now.
c6f530d70280 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22925
diff changeset
   911
     Transcript showCR:t.
c6f530d70280 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22925
diff changeset
   912
     Transcript showCR:(t addMilliseconds:1000).
c6f530d70280 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22925
diff changeset
   913
    "
22988
46b7e5b5dc48 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 22945
diff changeset
   914
46b7e5b5dc48 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 22945
diff changeset
   915
    "Modified: / 22-05-2018 / 16:52:37 / Stefan Vogel"
22945
c6f530d70280 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22925
diff changeset
   916
!
c6f530d70280 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22925
diff changeset
   917
6043
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   918
addMilliseconds:numberOfMilliSeconds
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   919
    "return a new instance of myself, numberOfMilliSeconds afterwards."
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   920
17015
f7c4867a3633 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16982
diff changeset
   921
    ^ self speciesNew 
22988
46b7e5b5dc48 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 22945
diff changeset
   922
        setMilliseconds:(self getMilliseconds + (numberOfMilliSeconds // 1 "this is inlined #truncated"))
22884
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
   923
        additionalPicoseconds:(self additionalPicoseconds 
22988
46b7e5b5dc48 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 22945
diff changeset
   924
                                + ((numberOfMilliSeconds \\ 1)*1000000000) truncated)
6043
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   925
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   926
    "
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   927
     |t|
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   928
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   929
     t := Timestamp now.
6043
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   930
     Transcript showCR:t.
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   931
     Transcript showCR:(t addMilliseconds:100).
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   932
    "
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   933
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   934
    "
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   935
     |t|
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   936
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   937
     t := Time now.
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   938
     Transcript showCR:t.
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   939
     Transcript showCR:(t addMilliseconds:1000).
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
   940
    "
22988
46b7e5b5dc48 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 22945
diff changeset
   941
46b7e5b5dc48 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 22945
diff changeset
   942
    "Modified: / 22-05-2018 / 17:03:20 / Stefan Vogel"
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   943
!
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   944
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   945
addMinutes:numberOfMinutes
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   946
    "return a new instance of myself, numberOfMinutes afterwards."
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   947
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   948
    ^ self addSeconds:(numberOfMinutes * 60)
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   949
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   950
    "
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   951
     |t|
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   952
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   953
     t := Timestamp now.
3476
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   954
     Transcript showCR:t.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   955
     Transcript showCR:(t addMinutes:60).
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   956
    "
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   957
3476
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   958
    "
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   959
     |t|
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
     t := Time now.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   962
     Transcript showCR:t.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   963
     Transcript showCR:(t addMinutes:60).
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   964
    "
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   965
!
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
   966
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   967
addSeconds:numberOfSeconds
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   968
    "return a new instance of myself, numberOfSeconds afterwards."
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   969
22884
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
   970
    ^ self addMilliseconds:(numberOfSeconds * 1000) 
3476
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   971
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   972
    "
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   973
     |t|
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   974
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
   975
     t := Timestamp now.
3476
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   976
     Transcript showCR:t.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   977
     Transcript showCR:(t addSeconds:60).
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   978
    "
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   979
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   980
    "
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   981
     |t|
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   982
3476
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   983
     t := Time now.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   984
     Transcript showCR:t.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   985
     Transcript showCR:(t addSeconds:60).
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   986
    "
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   987
!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   988
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   989
addTime:timeAmount
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   990
    "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
   991
     Provided for ST-80 compatibility.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   992
     WARNING:
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   993
        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
   994
        a numberOfSeconds as argument. 
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
   995
        Use any of addSeconds/addHours etc. to make things clear"
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   996
6888
d75cbe2e8ef7 addTime / subtractTime handle non-Number argument
Claus Gittinger <cg@exept.de>
parents: 6795
diff changeset
   997
    timeAmount isNumber ifFalse:[
d75cbe2e8ef7 addTime / subtractTime handle non-Number argument
Claus Gittinger <cg@exept.de>
parents: 6795
diff changeset
   998
        ^ self addSeconds:(timeAmount asSeconds).
d75cbe2e8ef7 addTime / subtractTime handle non-Number argument
Claus Gittinger <cg@exept.de>
parents: 6795
diff changeset
   999
    ].
3476
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  1000
    ^ self addSeconds:timeAmount
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1001
!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1002
16475
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
  1003
deltaFrom:aTimeOrInteger
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
  1004
    "return the delta as a timeDuration between 2 timeStamps.
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
  1005
     The argument is supposed to be BEFORE the receiver,
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
  1006
        computes self - aTimestamp"
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
  1007
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
  1008
    ^ aTimeOrInteger differenceFromTimestamp:self
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
  1009
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
  1010
    "
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
  1011
        Time now deltaFrom:10 minutes.
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
  1012
        Time now deltaFrom:3600.
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
  1013
        Time now deltaFrom:3600 seconds.
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
  1014
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
  1015
        Timestamp now deltaFrom:10 minutes.
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
  1016
        Timestamp now deltaFrom:3600.
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
  1017
        Timestamp now deltaFrom:3600 seconds.
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
  1018
    "
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
  1019
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
  1020
    "
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
  1021
     |t1 t2|
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
  1022
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
  1023
     t1 := Timestamp now.
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
  1024
     Delay waitForSeconds:0.5.
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
  1025
     t2 := Timestamp now.
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
  1026
     t2 deltaFrom:t1   
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
  1027
    "
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
  1028
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
  1029
    "Created: / 04-10-2007 / 13:34:28 / cg"
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
  1030
    "Modified: / 10-07-2010 / 09:37:01 / cg"
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
  1031
!
dd2e012601bf class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16407
diff changeset
  1032
16505
c285d94f2248 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16475
diff changeset
  1033
roundTo:aTimeDuration
21335
74daa1537978 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21325
diff changeset
  1034
    "round the receiver to the next multiple of a TimeDuration"
74daa1537978 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21325
diff changeset
  1035
    
16505
c285d94f2248 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16475
diff changeset
  1036
     ^ self class new setMilliseconds:(self getMilliseconds roundTo:aTimeDuration getMilliseconds)
c285d94f2248 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16475
diff changeset
  1037
c285d94f2248 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16475
diff changeset
  1038
    "
c285d94f2248 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16475
diff changeset
  1039
      (TimeDuration fromMilliseconds:25234) roundTo:2 seconds
c285d94f2248 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16475
diff changeset
  1040
      Time now roundTo:10 minutes
c285d94f2248 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16475
diff changeset
  1041
      Timestamp now roundTo:10 minutes
c285d94f2248 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16475
diff changeset
  1042
    "
c285d94f2248 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16475
diff changeset
  1043
!
c285d94f2248 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16475
diff changeset
  1044
6048
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
  1045
subtractDays:numberOfDays
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
  1046
    "return a new instance of myself, numberOfDays before."
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
  1047
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
  1048
    ^ self subtractSeconds:(numberOfDays * (60 * 60 * 24))
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
  1049
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
  1050
    "
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
  1051
     |t|
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
  1052
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
  1053
     t := Timestamp now.
6048
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
  1054
     Transcript showCR:t.
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
  1055
     Transcript showCR:(t subtractDays:50)
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
  1056
    "
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
  1057
!
af4b1127f362 refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 6043
diff changeset
  1058
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1059
subtractHours:numberOfHours
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1060
    "return a new instance of myself, numberOfHours before."
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1061
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1062
    ^ self subtractSeconds:(numberOfHours * (60 * 60))
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
  1063
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
  1064
    "
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
  1065
     |t|
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
  1066
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
  1067
     t := Timestamp now.
3476
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  1068
     Transcript showCR:t.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  1069
     Transcript showCR:(t subtractHours:12).
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  1070
    "
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  1071
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  1072
    "
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  1073
     |t|
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  1074
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  1075
     t := Time now.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  1076
     Transcript showCR:t.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  1077
     Transcript showCR:(t subtractHours:12).
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
  1078
    "
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
  1079
!
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
  1080
6043
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
  1081
subtractMilliseconds:numberOfMilliSeconds
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
  1082
    "return a new instance of myself, numberOfMilliSeconds before."
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
  1083
22884
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1084
    ^ self addMilliseconds:numberOfMilliSeconds negated 
6043
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
  1085
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
  1086
    "
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
  1087
     |t|
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
  1088
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
  1089
     t := Timestamp now.
6043
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
  1090
     Transcript showCR:t.
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
  1091
     Transcript showCR:(t subtractMilliseconds:100).
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
  1092
    "
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
  1093
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
  1094
    "
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
  1095
     |t|
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
  1096
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
  1097
     t := Time now.
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
  1098
     Transcript showCR:t.
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
  1099
     Transcript showCR:(t subtractMilliseconds:1000).
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
  1100
    "
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
  1101
!
ee486429674b pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents: 5968
diff changeset
  1102
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
  1103
subtractMinutes:numberOfMinutes
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
  1104
    "return a new instance of myself, numberOfMinutes before."
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
  1105
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
  1106
    ^ self subtractSeconds:(numberOfMinutes * 60)
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
  1107
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
  1108
    "
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
  1109
     |t|
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
  1110
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
  1111
     t := Timestamp now.
3476
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  1112
     Transcript showCR:t.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  1113
     Transcript showCR:(t subtractMinutes:60).
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  1114
    "
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  1115
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  1116
    "
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  1117
     |t|
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  1118
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  1119
     t := Time now.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  1120
     Transcript showCR:t.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  1121
     Transcript showCR:(t subtractMinutes:60).
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
  1122
    "
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
  1123
!
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
  1124
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1125
subtractSeconds:numberOfSeconds
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1126
    "return a new instance of myself, numberOfSeconds before."
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
  1127
22884
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1128
    ^ self addMilliseconds:(numberOfSeconds * -1000) 
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
  1129
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
  1130
    "
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
  1131
     |t|
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
  1132
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
  1133
     t := Timestamp now.
3476
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  1134
     Transcript showCR:t.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  1135
     Transcript showCR:(t subtractSeconds:60).
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  1136
    "
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  1137
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
  1138
    "
3476
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  1139
     |t|
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  1140
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  1141
     t := Time now.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  1142
     Transcript showCR:t.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  1143
     Transcript showCR:(t subtractSeconds:60).
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  1144
    "
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
  1145
!
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
  1146
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
  1147
subtractTime:timeAmount
3476
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  1148
    "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
  1149
     Provided for ST-80 compatibility.
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  1150
     WARNING:
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  1151
        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
  1152
        a numberOfSeconds as argument. 
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  1153
        Use any of addSeconds/addHours etc. to make things clear"
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
  1154
6888
d75cbe2e8ef7 addTime / subtractTime handle non-Number argument
Claus Gittinger <cg@exept.de>
parents: 6795
diff changeset
  1155
    timeAmount isNumber ifFalse:[
d75cbe2e8ef7 addTime / subtractTime handle non-Number argument
Claus Gittinger <cg@exept.de>
parents: 6795
diff changeset
  1156
        ^ self subtractSeconds:(timeAmount asSeconds).
d75cbe2e8ef7 addTime / subtractTime handle non-Number argument
Claus Gittinger <cg@exept.de>
parents: 6795
diff changeset
  1157
    ].
3476
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  1158
    ^ self subtractSeconds:timeAmount
f2ebb76a952d dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  1159
16505
c285d94f2248 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16475
diff changeset
  1160
!
c285d94f2248 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16475
diff changeset
  1161
c285d94f2248 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16475
diff changeset
  1162
truncateTo:aTimeDuration
21335
74daa1537978 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21325
diff changeset
  1163
    "truncate the receiver to the next multiple of a TimeDuration"
74daa1537978 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21325
diff changeset
  1164
16505
c285d94f2248 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16475
diff changeset
  1165
     ^ self class new setMilliseconds:(self getMilliseconds truncateTo:aTimeDuration getMilliseconds)
c285d94f2248 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16475
diff changeset
  1166
c285d94f2248 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16475
diff changeset
  1167
    "
c285d94f2248 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16475
diff changeset
  1168
      (TimeDuration fromMilliseconds:25234) truncateTo:2 seconds
c285d94f2248 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16475
diff changeset
  1169
      Time now truncateTo:10 minutes
c285d94f2248 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16475
diff changeset
  1170
      Timestamp now truncateTo:10 minutes
c285d94f2248 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16475
diff changeset
  1171
    "
275
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
  1172
! !
a76029ddaa98 *** empty log message ***
claus
parents: 240
diff changeset
  1173
5573
efd0dc6578ac #-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 5548
diff changeset
  1174
!AbstractTime methodsFor:'comparing'!
efd0dc6578ac #-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 5548
diff changeset
  1175
22884
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1176
< aTimeOrTimeDurationOrNumberOfSeconds
5573
efd0dc6578ac #-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 5548
diff changeset
  1177
    "return true if the receiver is before the argument"
efd0dc6578ac #-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 5548
diff changeset
  1178
22884
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1179
    |myMilliseconds otherMilliseconds myPicos otherPicos|
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1180
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1181
    myMilliseconds := self getMilliseconds.
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1182
    myPicos := self additionalPicoseconds.
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1183
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1184
    aTimeOrTimeDurationOrNumberOfSeconds isNumber ifTrue:[
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1185
        "backward compatibility for old code, which expects (time1 - time2) to return seconds"    
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1186
        otherMilliseconds := (aTimeOrTimeDurationOrNumberOfSeconds * 1000) asInteger.   "integer seconds"
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1187
        otherPicos := 0.
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1188
    ] ifFalse:[
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1189
        otherMilliseconds := aTimeOrTimeDurationOrNumberOfSeconds getMilliseconds.
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1190
        otherPicos := aTimeOrTimeDurationOrNumberOfSeconds additionalPicoseconds.
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1191
    ].
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1192
    ^ (myMilliseconds < otherMilliseconds)
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1193
    or:[ myMilliseconds = otherMilliseconds and:[myPicos < otherPicos ]].
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1194
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1195
    "
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1196
        (Timestamp now + 10) - Timestamp now  < 10
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1197
        (Timestamp now + 10) - Timestamp now  < 11
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1198
    "
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1199
!
5573
efd0dc6578ac #-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 5548
diff changeset
  1200
22884
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1201
<= aTimeOrTimeDurationOrNumberOfSeconds
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1202
    "return true if the receiver is before or the same time as the argument"
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1203
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1204
    |myMilliseconds otherMilliseconds myPicos otherPicos|
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1205
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1206
    myMilliseconds := self getMilliseconds.
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1207
    myPicos := self additionalPicoseconds.
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1208
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1209
    aTimeOrTimeDurationOrNumberOfSeconds isNumber ifTrue:[
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1210
        "backward compatibility for old code, which expects (time1 - time2) to return seconds"    
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1211
        otherMilliseconds := (aTimeOrTimeDurationOrNumberOfSeconds * 1000) asInteger.   "integer seconds"
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1212
        otherPicos := 0.
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1213
    ] ifFalse:[
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1214
        otherMilliseconds := aTimeOrTimeDurationOrNumberOfSeconds getMilliseconds.
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1215
        otherPicos := aTimeOrTimeDurationOrNumberOfSeconds additionalPicoseconds.
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1216
    ].
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1217
    ^ (myMilliseconds < otherMilliseconds)
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1218
    or:[ myMilliseconds = otherMilliseconds and:[myPicos <= otherPicos ]].
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1219
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1220
    "
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1221
        (Timestamp now + 10) - Timestamp now  <= 10
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1222
        (Timestamp now + 10) - Timestamp now  <= 11
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1223
        (Timestamp now + 10) - Timestamp now  <= 9
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1224
    "
5573
efd0dc6578ac #-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 5548
diff changeset
  1225
!
efd0dc6578ac #-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 5548
diff changeset
  1226
22884
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1227
= aTimeOrTimeDurationOrNumberOfSeconds
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1228
    "return true if the receiver is before or the same time as the argument"
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1229
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1230
    |myMilliseconds otherMilliseconds myPicos otherPicos|
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1231
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1232
    myMilliseconds := self getMilliseconds.
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1233
    myPicos := self additionalPicoseconds.
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1234
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1235
    aTimeOrTimeDurationOrNumberOfSeconds isNumber ifTrue:[
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1236
        "backward compatibility for old code, which expects (time1 - time2) to return seconds"    
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1237
        otherMilliseconds := (aTimeOrTimeDurationOrNumberOfSeconds * 1000) asInteger.   "integer seconds"
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1238
        otherPicos := 0.
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1239
    ] ifFalse:[
22913
c74635278990 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22884
diff changeset
  1240
        self speciesForCompare = aTimeOrTimeDurationOrNumberOfSeconds speciesForCompare ifFalse:[   
c74635278990 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22884
diff changeset
  1241
            ^ false        
c74635278990 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22884
diff changeset
  1242
        ].
22884
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1243
        otherMilliseconds := aTimeOrTimeDurationOrNumberOfSeconds getMilliseconds.
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1244
        otherPicos := aTimeOrTimeDurationOrNumberOfSeconds additionalPicoseconds.
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1245
    ].
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1246
    ^ (myMilliseconds = otherMilliseconds) and:[myPicos = otherPicos ].
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1247
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1248
    "
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1249
        (Timestamp now + 10) - Timestamp now  = 10
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1250
        (Timestamp now + 10) - Timestamp now  = 9
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1251
22913
c74635278990 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22884
diff changeset
  1252
        (Timestamp now) = (Timestamp now + 10 - 10)
c74635278990 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22884
diff changeset
  1253
        (Timestamp now) = (UtcTimestamp now)
c74635278990 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22884
diff changeset
  1254
22884
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1255
        (Time now + 10 seconds) - Time now  = 10
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1256
        (Time now + 10) - Time now          = 10
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1257
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1258
        (Time now + 10 seconds) > Time now 
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1259
        (Time now + 10)         > Time now      
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1260
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1261
        (Time now + 10 milliSeconds) > Time now 
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1262
        (Time now + 0 milliseconds)  > Time now      
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1263
    "
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1264
!
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1265
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1266
> aTimeOrTimeDurationOrNumberOfSeconds
5573
efd0dc6578ac #-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 5548
diff changeset
  1267
    "return true if the receiver is after the argument"
efd0dc6578ac #-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 5548
diff changeset
  1268
22884
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1269
    |myMilliseconds otherMilliseconds myPicos otherPicos|
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1270
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1271
    myMilliseconds := self getMilliseconds.
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1272
    myPicos := self additionalPicoseconds.
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1273
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1274
    aTimeOrTimeDurationOrNumberOfSeconds isNumber ifTrue:[
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1275
        "backward compatibility for old code, which expects (time1 - time2) to return seconds"    
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1276
        otherMilliseconds := (aTimeOrTimeDurationOrNumberOfSeconds * 1000) asInteger.   "integer seconds"
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1277
        otherPicos := 0.
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1278
    ] ifFalse:[
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1279
        otherMilliseconds := aTimeOrTimeDurationOrNumberOfSeconds getMilliseconds.
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1280
        otherPicos := aTimeOrTimeDurationOrNumberOfSeconds additionalPicoseconds.
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1281
    ].
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1282
    ^ (myMilliseconds > otherMilliseconds)
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1283
    or:[ myMilliseconds = otherMilliseconds and:[myPicos > otherPicos ]].
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1284
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1285
    "
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1286
        (Timestamp now + 10) - Timestamp now  > 10
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1287
        (Timestamp now + 10) - Timestamp now  > 9
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1288
    "
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1289
!
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1290
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1291
>= aTimeOrTimeDurationOrNumberOfSeconds
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1292
    "return true if the receiver is after the argument or the same"
5573
efd0dc6578ac #-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 5548
diff changeset
  1293
22884
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1294
    |myMilliseconds otherMilliseconds myPicos otherPicos|
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1295
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1296
    myMilliseconds := self getMilliseconds.
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1297
    myPicos := self additionalPicoseconds.
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1298
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1299
    aTimeOrTimeDurationOrNumberOfSeconds isNumber ifTrue:[
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1300
        "backward compatibility for old code, which expects (time1 - time2) to return seconds"    
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1301
        otherMilliseconds := (aTimeOrTimeDurationOrNumberOfSeconds * 1000) asInteger.   "integer seconds"
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1302
        otherPicos := 0.
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1303
    ] ifFalse:[
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1304
        otherMilliseconds := aTimeOrTimeDurationOrNumberOfSeconds getMilliseconds.
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1305
        otherPicos := aTimeOrTimeDurationOrNumberOfSeconds additionalPicoseconds.
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1306
    ].
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1307
    ^ (myMilliseconds > otherMilliseconds)
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1308
    or:[ myMilliseconds = otherMilliseconds and:[myPicos >= otherPicos ]].
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1309
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1310
    "
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1311
        (Timestamp now + 10) - Timestamp now  >= 11
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1312
        (Timestamp now + 10) - Timestamp now  >= 10
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1313
        (Timestamp now + 10) - Timestamp now  >= 9
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1314
    "
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1315
!
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1316
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1317
hash
3c29351e939e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22845
diff changeset
  1318
    ^ self getMilliseconds
5573
efd0dc6578ac #-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 5548
diff changeset
  1319
! !
efd0dc6578ac #-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents: 5548
diff changeset
  1320
8200
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
  1321
!AbstractTime methodsFor:'converting'!
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
  1322
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
  1323
asAbsoluteTime
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
  1324
    "deprecated, use #asTimestamp"
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
  1325
    <resource:#obsolete>
8200
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
  1326
12002
3ecffb2d77ad *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11772
diff changeset
  1327
    self obsoleteMethodWarning:'use #asTimestamp'.
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
  1328
    ^ self asTimestamp
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
  1329
!
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
  1330
13233
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
  1331
asLocalTimestamp
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
  1332
    "represent myself as a timestamp in the local timezone"
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
  1333
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
  1334
    ^ self subclassResponsibility
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
  1335
!
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
  1336
17140
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
  1337
asMilliseconds
22836
1c878b36a068 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22826
diff changeset
  1338
    "return the number of milliseconds elapsed since some starttime,
1c878b36a068 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22826
diff changeset
  1339
     which is subclass specific (i.e. Time: since midnight; Timestamp: since the epoch).
1c878b36a068 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22826
diff changeset
  1340
     Use this only to compute relative millisecond deltas."
17140
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
  1341
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
  1342
    ^ self getMilliseconds
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
  1343
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
  1344
    "
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
  1345
     Time now asMilliseconds
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
  1346
     Timestamp now asMilliseconds
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
  1347
     (TimeDuration days:1) asMilliseconds
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
  1348
     (TimeDuration hours:1) asMilliseconds
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
  1349
    "
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
  1350
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
  1351
    "Created: / 05-09-2011 / 10:40:15 / cg"
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
  1352
!
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
  1353
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
  1354
asSeconds
19398
7384b2086a5d #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 19198
diff changeset
  1355
    "get the seconds since some point of time in the past.
7384b2086a5d #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 19198
diff changeset
  1356
     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
  1357
     For TimeDurations, that is the duration in seconds (truncated);
19398
7384b2086a5d #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 19198
diff changeset
  1358
     For TimeStamps, that is the number of seconds since the epoch"
17140
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
  1359
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
  1360
    ^ self getSeconds
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
  1361
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
  1362
    "
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
  1363
     Timestamp now asSeconds
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
  1364
     Time now asSeconds
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
  1365
     (TimeDuration days:1) asSeconds
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
  1366
    "
22283
3edefecbb6b6 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22036
diff changeset
  1367
3edefecbb6b6 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22036
diff changeset
  1368
    "Modified (comment): / 21-09-2017 / 18:49:31 / cg"
17140
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
  1369
!
9369deba01dc class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 17015
diff changeset
  1370
23235
acf3d6e991aa #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23020
diff changeset
  1371
asTZTimestamp
acf3d6e991aa #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23020
diff changeset
  1372
    "raise an error: must be redefined in concrete subclass(es)"
acf3d6e991aa #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23020
diff changeset
  1373
acf3d6e991aa #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23020
diff changeset
  1374
    ^ self subclassResponsibility
acf3d6e991aa #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23020
diff changeset
  1375
!
acf3d6e991aa #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23020
diff changeset
  1376
22036
bb2ede52a8f0 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21671
diff changeset
  1377
asTime
bb2ede52a8f0 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21671
diff changeset
  1378
    "return a Time object from the receiver."
bb2ede52a8f0 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21671
diff changeset
  1379
bb2ede52a8f0 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21671
diff changeset
  1380
    ^ 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
  1381
bb2ede52a8f0 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21671
diff changeset
  1382
    "
bb2ede52a8f0 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21671
diff changeset
  1383
     (1 seconds + 0.01 seconds) asTime
bb2ede52a8f0 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21671
diff changeset
  1384
    "
bb2ede52a8f0 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21671
diff changeset
  1385
bb2ede52a8f0 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21671
diff changeset
  1386
    "Created: / 17-07-2017 / 13:57:54 / cg"
bb2ede52a8f0 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21671
diff changeset
  1387
!
bb2ede52a8f0 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21671
diff changeset
  1388
8256
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
  1389
asTimestamp
13233
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
  1390
    "represent myself as a Timestamp"
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
  1391
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
  1392
    ^ self subclassResponsibility
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
  1393
!
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
  1394
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
  1395
asUtcTimestamp
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
  1396
    "represent myself as a timestamp in the local timezone"
Stefan Vogel <sv@exept.de>
parents: 13175
diff changeset
  1397
8200
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
  1398
    ^ self subclassResponsibility
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
  1399
! !
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
  1400
22632
df853ecc851b #BUGFIX by mawalch
mawalch
parents: 22626
diff changeset
  1401
!AbstractTime methodsFor:'double dispatching'!
df853ecc851b #BUGFIX by mawalch
mawalch
parents: 22626
diff changeset
  1402
df853ecc851b #BUGFIX by mawalch
mawalch
parents: 22626
diff changeset
  1403
differenceFromTimestamp:aTimestamp
22945
c6f530d70280 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22925
diff changeset
  1404
    "return the time difference as a timeDuration instance"
22632
df853ecc851b #BUGFIX by mawalch
mawalch
parents: 22626
diff changeset
  1405
23235
acf3d6e991aa #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23020
diff changeset
  1406
    ^ self subclassResponsibility.
acf3d6e991aa #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23020
diff changeset
  1407
acf3d6e991aa #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23020
diff changeset
  1408
    "Modified: / 27-07-2018 / 11:30:27 / Stefan Vogel"
22632
df853ecc851b #BUGFIX by mawalch
mawalch
parents: 22626
diff changeset
  1409
! !
df853ecc851b #BUGFIX by mawalch
mawalch
parents: 22626
diff changeset
  1410
22913
c74635278990 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22884
diff changeset
  1411
4649
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1412
!AbstractTime methodsFor:'printing & storing'!
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1413
16829
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1414
addBasicPrintBindingsTo:aDictionary language:languageOrNil
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1415
    "private print support: add bindings for printing to aDictionary.
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1416
     languageOrNil can be #en, #fr, #de or nil for the current language.
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1417
     Here only basic bindings are added - no timezone am am/pm stuff,
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1418
     which doesn't make sense for TimeDuration.
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1419
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1420
     bindings:
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1421
        %h      hours, 00..23 (i.e. european)  0-padded to length 2
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1422
        %m      minutes, 00..59                0-padded to length 2
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1423
        %s      seconds, 00..59                0-padded to length 2
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1424
        %i      milliseconds, 000..999         0-padded to length 3
22626
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1425
        %j      microseconds, 000000..999999   0-padded to length 6
16829
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1426
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1427
     Timestamp only:
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1428
        %(day)   day, 00..31                    0-padded to length 2
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1429
        %(month) month, 00..12                  0-padded to length 2
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1430
        %(year)  year, 4 digits                 0-padded to length 4
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1431
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1432
     special:
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1433
        %H      24-hours - unpadded
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1434
        %M      minutes - unpadded
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1435
        %S      seconds - unpadded
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1436
        %I      milliseconds, unpadded
22626
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1437
        %J      microseconds, unpadded
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1438
        %F      subsecond fraction, unpadded with as many post-digits as appropriate
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1439
                (i.e. for .1 , .01 , .001 etc.)
16829
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1440
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1441
        %t      seconds within hour  (unpadded)
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1442
        %T      seconds from midNight  (unpadded)
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1443
22626
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1444
        %(milli) milliseconds unpadded - alias for %I for convenience
20200
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1445
        %(milli1) milliseconds, truncated to 1/10th of a second 0..9
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1446
        %(milli2) milliseconds, truncated to 1/100th of a second 00..99 0-padded to length 2
22845
dfdd78f1f144 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22838
diff changeset
  1447
        %(milli3) milliseconds, padded to 3 (same as %i for convenience)
22995
cf5b68a4bca7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22988
diff changeset
  1448
        %(milliF1) milliseconds + 1 digits of micros
cf5b68a4bca7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22988
diff changeset
  1449
        %(milliF2) milliseconds + 2 digits of micros
cf5b68a4bca7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22988
diff changeset
  1450
        %(milliF3) milliseconds + 3 digits of micros
cf5b68a4bca7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22988
diff changeset
  1451
        %(milliF4) milliseconds + 4 digits of micros
16829
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1452
22626
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1453
        %(micro) microseconds unpadded - alias for %J for convenience
22845
dfdd78f1f144 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22838
diff changeset
  1454
        %(micro6) microseconds, padded to 6 (same as %j for convenience)
dfdd78f1f144 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22838
diff changeset
  1455
dfdd78f1f144 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22838
diff changeset
  1456
        %(nano) nanoseconds unpadded
dfdd78f1f144 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22838
diff changeset
  1457
        %(nano9) nanoseconds, padded to 9
22626
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1458
22845
dfdd78f1f144 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22838
diff changeset
  1459
        %(pico) picoseconds unpadded
dfdd78f1f144 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22838
diff changeset
  1460
        %(pico12) picoseconds, padded to 12
dfdd78f1f144 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22838
diff changeset
  1461
dfdd78f1f144 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22838
diff changeset
  1462
        %(fract) fraction part - as many as needed alias for %F for convenience
22626
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1463
16829
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1464
     Timestamp only:
20200
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1465
        %(Day)         - day - unpadded
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1466
        %(Month)       - month - unpadded
16829
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1467
        %(yearOrTime)  - year or time 5 digits    as in unix-ls:
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1468
                                                  year if it is not the current year;
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1469
                                                  time otherwise
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1470
        %(weekDay)      - day in week (1->monday, 2->tuesday, ... ,7->sunday)
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1471
20200
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1472
        %(dayName)      - full day name
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1473
        %(DayName)      - full day name, first character uppercase
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1474
        %(DAYNAME)      - full day name, all uppercase
16829
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1475
20200
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1476
        %(monthName)    - full month name
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1477
        %(MonthName)    - full month name, first character uppercase
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1478
        %(MONTHNAME)    - full month name, all uppercase
16829
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1479
20200
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1480
        %(shortDayName) - short (abbreviated) day name
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1481
        %(ShortDayName) - short (abbreviated) day name, first character uppercase
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1482
        %(SHORTDAYNAME) - short (abbreviated) day name, all uppercase
16829
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1483
20200
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1484
        %(shortMonthName) - short (abbreviated) month name
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1485
        %(ShortMonthName) - short (abbreviated) month name, first character uppercase
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1486
        %(SHORTMONTHNAME) - short (abbreviated) month name, all uppercase
16829
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1487
20200
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1488
        %(nth)          - counting day-in-month (1->'st'; 2->'nd'; 3->'rd'; 4...->'th')
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1489
        %(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
  1490
        %(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
  1491
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1492
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1493
     The ISO8601 printString are generated with:
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1494
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1495
       Year:
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1496
          YYYY (eg 1997)
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1497
                Date today printStringFormat:'%(year)'
20200
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1498
                Timestamp now printStringFormat:'%(year)'
16829
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1499
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1500
       Year and month:
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1501
          YYYY-MM (eg 1997-07)
20200
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1502
                Date today printStringFormat:'%(year)-%(month)'
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1503
                Timestamp now printStringFormat:'%(year)-%(month)'
16829
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1504
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1505
       Complete date:
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1506
          YYYY-MM-DD (eg 1997-07-16)
20200
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1507
                Date today printStringFormat:'%(year)-%(month)-%(day)'
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1508
                Timestamp now printStringFormat:'%(year)-%(month)-%(day)'
16829
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1509
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1510
       Complete date plus hours and minutes:
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1511
          YYYY-MM-DDThh:mmTZD (eg 1997-07-16T19:20+01:00)
20200
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1512
                Timestamp now printStringFormat:'%(year)-%(month)-%(day)T%h:%m%(TZD)'
16829
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1513
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1514
       Complete date plus hours, minutes and seconds:
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1515
          YYYY-MM-DDThh:mm:ssTZD (eg 1997-07-16T19:20:30+01:00)
20200
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1516
                Timestamp now printStringFormat:'%(year)-%(month)-%(day)T%h:%m:%s%(TZD)'
16829
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1517
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1518
       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
  1519
          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
  1520
                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
  1521
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1522
    "
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1523
22845
dfdd78f1f144 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22838
diff changeset
  1524
    |time hours minutes seconds millis micros nanos picos 
22626
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1525
     millisZ3 picosZ9 fract012 fract s t|
16829
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1526
23020
5c413c4c1188 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22995
diff changeset
  1527
    aDictionary at:#'iso8601'         put:[ self printStringIso8601 ].
5c413c4c1188 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22995
diff changeset
  1528
    aDictionary at:#'iso8601_compact' put:[ self printStringIso8601Compressed ].
5c413c4c1188 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22995
diff changeset
  1529
16926
755f4c452bf4 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16829
diff changeset
  1530
    time := self asTime.
755f4c452bf4 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16829
diff changeset
  1531
    hours := time hours.
755f4c452bf4 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16829
diff changeset
  1532
    minutes := time minutes.
755f4c452bf4 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16829
diff changeset
  1533
    seconds := time seconds.
16829
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1534
    millis := self milliseconds.
22626
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1535
    micros := self microseconds.
22845
dfdd78f1f144 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22838
diff changeset
  1536
    nanos := self nanoseconds.
22626
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1537
    picos := self picoseconds.
16829
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1538
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1539
    aDictionary at:$H put:(s := hours printString).
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1540
    aDictionary at:$h put:(s leftPaddedTo:2 with:$0).
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1541
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1542
    aDictionary at:$M put:(s := minutes printString).
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1543
    aDictionary at:$m put:(s leftPaddedTo:2 with:$0).
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1544
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1545
    aDictionary at:$S put:(s := seconds printString).
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1546
    aDictionary at:$s put:(s leftPaddedTo:2 with:$0).
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1547
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1548
    aDictionary at:$I put:(s := millis printString).
22626
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1549
    aDictionary at:#milli put:s.
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1550
    aDictionary at:$i put:(millisZ3 := s leftPaddedTo:3 with:$0).
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1551
    aDictionary at:#milli3 put:millisZ3.
16829
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1552
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1553
    aDictionary at:#milli1 put:((millis // 100) printString).
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1554
    aDictionary at:#milli2 put:((millis // 10) printStringLeftPaddedTo:2 with:$0).
22995
cf5b68a4bca7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22988
diff changeset
  1555
    aDictionary at:#milliF1 put:((micros asFixedPoint:1) / 1000).
cf5b68a4bca7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22988
diff changeset
  1556
    aDictionary at:#milliF2 put:((micros asFixedPoint:2) / 1000).
cf5b68a4bca7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22988
diff changeset
  1557
    aDictionary at:#milliF3 put:((micros asFixedPoint:3) / 1000).
23602
fcf3d6f2f944 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23235
diff changeset
  1558
    aDictionary at:#milliF4 put:((nanos asFixedPoint:4) / 1000000).
16829
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1559
22626
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1560
    aDictionary at:$J put:(s := micros printString).
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1561
    aDictionary at:#micro put:s.
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1562
    aDictionary at:$j put:(t := s leftPaddedTo:6 with:$0).
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1563
    aDictionary at:#micro6 put:t.
22995
cf5b68a4bca7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22988
diff changeset
  1564
    aDictionary at:#microF1 put:((nanos asFixedPoint:1) / 1000).
cf5b68a4bca7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22988
diff changeset
  1565
    aDictionary at:#microF2 put:((nanos asFixedPoint:2) / 1000).
cf5b68a4bca7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22988
diff changeset
  1566
    aDictionary at:#microF3 put:((nanos asFixedPoint:3) / 1000).
23602
fcf3d6f2f944 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23235
diff changeset
  1567
    aDictionary at:#microF4 put:((picos asFixedPoint:4) / 1000000).
22626
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1568
22845
dfdd78f1f144 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22838
diff changeset
  1569
    aDictionary at:#nano put:(s := nanos printString).
dfdd78f1f144 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22838
diff changeset
  1570
    aDictionary at:#nano9 put:(s leftPaddedTo:9 with:$0).
dfdd78f1f144 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22838
diff changeset
  1571
dfdd78f1f144 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22838
diff changeset
  1572
    aDictionary at:#pico put:(s := picos printString).
dfdd78f1f144 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22838
diff changeset
  1573
    aDictionary at:#pico12 put:(s leftPaddedTo:12 with:$0).
dfdd78f1f144 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22838
diff changeset
  1574
22626
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1575
    picosZ9 := self picoseconds printString leftPaddedTo:9 with:$0.
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1576
    fract012 := millisZ3,picosZ9.
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1577
    fract := fract012 copyTo:(fract012 findLast:[:ch | ch ~~ $0] ifNone:12).
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1578
    aDictionary at:$F put:fract.
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1579
    aDictionary at:#fract put:fract.
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1580
16829
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1581
    aDictionary at:$t put:(seconds * minutes) printString.
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1582
    aDictionary at:$T put:(seconds * minutes * hours) printString.
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1583
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1584
    "
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1585
      |dict|
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1586
      dict := Dictionary new.
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1587
      Timestamp now addBasicPrintBindingsTo:dict language:#en.
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1588
      dict inspect
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1589
    "
22626
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1590
    "
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1591
      Timestamp now printStringFormat:'%(milli)'        -- millis only  
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1592
      Timestamp now printStringFormat:'%(milli3)'       -- millis padded  
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1593
      Timestamp now printStringFormat:'%(micro6)'       -- micros padded  
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1594
      Timestamp now printStringFormat:'%(fract)'        -- fraction part - as needed
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1595
      Timestamp nowWithMicroseconds printStringFormat:'%(fract)'        -- fraction part - as needed
22995
cf5b68a4bca7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22988
diff changeset
  1596
cf5b68a4bca7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22988
diff changeset
  1597
      (TimeDuration fromMicroseconds:30) printStringFormat:'%(milliF1)ms'
cf5b68a4bca7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22988
diff changeset
  1598
      (TimeDuration fromMicroseconds:30) printStringFormat:'%(milliF2)ms'
cf5b68a4bca7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22988
diff changeset
  1599
      (TimeDuration fromMicroseconds:30) printStringFormat:'%(milliF3)ms'
cf5b68a4bca7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22988
diff changeset
  1600
      (TimeDuration fromMicroseconds:30) printStringFormat:'%(milliF4)ms'
23602
fcf3d6f2f944 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23235
diff changeset
  1601
      (TimeDuration fromMicroseconds:3) printStringFormat:'%(milliF4)ms'
fcf3d6f2f944 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23235
diff changeset
  1602
      (TimeDuration fromNanoseconds:300) printStringFormat:'%(milliF4)us'
22995
cf5b68a4bca7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22988
diff changeset
  1603
cf5b68a4bca7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22988
diff changeset
  1604
      (TimeDuration fromNanoseconds:30) printStringFormat:'%(microF1)us'
cf5b68a4bca7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22988
diff changeset
  1605
      (TimeDuration fromNanoseconds:30) printStringFormat:'%(microF2)us'
cf5b68a4bca7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22988
diff changeset
  1606
      (TimeDuration fromNanoseconds:30) printStringFormat:'%(microF3)us'
cf5b68a4bca7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22988
diff changeset
  1607
      (TimeDuration fromNanoseconds:30) printStringFormat:'%(microF4)us'
23602
fcf3d6f2f944 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23235
diff changeset
  1608
      (TimeDuration fromNanoseconds:3) printStringFormat:'%(microF4)us'
fcf3d6f2f944 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23235
diff changeset
  1609
      (TimeDuration fromPicoseconds:300) printStringFormat:'%(microF4)us'
22626
89f954dcc609 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22618
diff changeset
  1610
    "
22995
cf5b68a4bca7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22988
diff changeset
  1611
23602
fcf3d6f2f944 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23235
diff changeset
  1612
    "Modified (comment): / 14-01-2019 / 18:21:38 / Claus Gittinger"
16829
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1613
!
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1614
4844
6938f0df31f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4841
diff changeset
  1615
addPrintBindingsTo:aDictionary
16829
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1616
    <resource: #obsolete>
8111
67347b7e3e69 print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents: 7672
diff changeset
  1617
16829
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1618
    self obsoleteMethodWarning:'use #addPrintBindingsTo:language:'.
8111
67347b7e3e69 print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents: 7672
diff changeset
  1619
    self addPrintBindingsTo:aDictionary language:nil
67347b7e3e69 print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents: 7672
diff changeset
  1620
!
67347b7e3e69 print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents: 7672
diff changeset
  1621
67347b7e3e69 print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents: 7672
diff changeset
  1622
addPrintBindingsTo:aDictionary language:languageOrNil
67347b7e3e69 print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents: 7672
diff changeset
  1623
    "private print support: add bindings for printing to aDictionary.
13175
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1624
     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
  1625
11772
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1626
     bindings:
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1627
        %h      hours, 00..23 (i.e. european)  0-padded to length 2
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1628
        %u      hours, 00..12 (i.e. us)        0-padded to length 2
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1629
        %m      minutes, 00..59                0-padded to length 2
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1630
        %s      seconds, 00..59                0-padded to length 2
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1631
        %i      milliseconds, 000..999         0-padded to length 3
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1632
        %a      am/pm
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1633
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1634
     Timestamp only:
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1635
        %(day)   day, 00..31                    0-padded to length 2
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1636
        %(month) month, 00..12                  0-padded to length 2
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1637
        %(year)  year, 4 digits                 0-padded to length 4
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1638
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1639
     special:
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1640
        %H      24-hours - unpadded
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1641
        %U      12-hours - unpadded
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1642
        %M      minutes - unpadded
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1643
        %S      seconds - unpadded
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1644
        %I      milliseconds, unpadded
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1645
        %A      AM/PM   - uppercase
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1646
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1647
        %t      seconds within hour  (unpadded)
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1648
        %T      seconds from midNight  (unpadded)
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1649
20200
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1650
        %(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
  1651
20200
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1652
        %(milli1) milliseconds, truncated to 1/10th of a second 0..9
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1653
        %(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
  1654
        %(milli3) milliseconds, same as %i for convenience
11772
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1655
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1656
     Timestamp only:
20200
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1657
        %(Day)         - day - unpadded
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1658
        %(Month)       - month - unpadded
13175
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1659
        %(yearOrTime)  - year or time 5 digits    as in unix-ls:
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1660
                                                  year if it is not the current year;
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1661
                                                  time otherwise
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1662
        %(weekDay)      - day in week (1->monday, 2->tuesday, ... ,7->sunday)
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1663
20200
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1664
        %(dayName)      - full day name
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1665
        %(DayName)      - full day name, first character uppercase
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1666
        %(DAYNAME)      - full day name, all uppercase
13175
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1667
20200
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1668
        %(monthName)    - full month name
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1669
        %(MonthName)    - full month name, first character uppercase
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1670
        %(MONTHNAME)    - full month name, all uppercase
13175
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1671
20200
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1672
        %(shortDayName) - short (abbreviated) day name
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1673
        %(ShortDayName) - short (abbreviated) day name, first character uppercase
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1674
        %(SHORTDAYNAME) - short (abbreviated) day name, all uppercase
13175
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1675
20200
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1676
        %(shortMonthName) - short (abbreviated) month name
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1677
        %(ShortMonthName) - short (abbreviated) month name, first character uppercase
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1678
        %(SHORTMONTHNAME) - short (abbreviated) month name, all uppercase
13175
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1679
20200
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1680
        %(nth)          - counting day-in-month (1->'st'; 2->'nd'; 3->'rd'; 4...->'th')
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1681
        %(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
  1682
        %(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
  1683
20200
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1684
        %(yearRoman)    - year, in roman letters
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1685
        %(monthRoman)   - month, in roman letters
17195
8c13747ba36d class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 17140
diff changeset
  1686
11772
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1687
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1688
     The ISO8601 printString are generated with:
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1689
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1690
       Year:
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1691
          YYYY (eg 1997)
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1692
                Date today printStringFormat:'%(year)'
20200
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1693
                Timestamp now printStringFormat:'%(year)'
11772
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1694
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1695
       Year and month:
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1696
          YYYY-MM (eg 1997-07)
20200
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1697
                Date today printStringFormat:'%(year)-%(month)'
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1698
                Timestamp now printStringFormat:'%(year)-%(month)'
11772
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1699
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1700
       Complete date:
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1701
          YYYY-MM-DD (eg 1997-07-16)
20200
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1702
                Date today printStringFormat:'%(year)-%(month)-%(day)'
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1703
                Timestamp now printStringFormat:'%(year)-%(month)-%(day)'
11772
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1704
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1705
       Complete date plus hours and minutes:
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1706
          YYYY-MM-DDThh:mmTZD (eg 1997-07-16T19:20+01:00)
20200
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1707
                Timestamp now printStringFormat:'%(year)-%(month)-%(day)T%h:%m%(TZD)'
11772
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1708
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1709
       Complete date plus hours, minutes and seconds:
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1710
          YYYY-MM-DDThh:mm:ssTZD (eg 1997-07-16T19:20:30+01:00)
20200
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1711
                Timestamp now printStringFormat:'%(year)-%(month)-%(day)T%h:%m:%s%(TZD)'
11772
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1712
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1713
       Complete date plus hours, minutes, seconds and a decimal fraction of a second
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1714
          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
  1715
                Timestamp now printStringFormat:'%(year)-%(month)-%(day)T%h:%m:%s.%(milli2)%(TZD)'
11772
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1716
a220d63dfc64 comment
Claus Gittinger <cg@exept.de>
parents: 11771
diff changeset
  1717
    "
4844
6938f0df31f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4841
diff changeset
  1718
16829
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1719
    |usHours ampm s zone tzDelta|
4844
6938f0df31f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4841
diff changeset
  1720
16829
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1721
    self addBasicPrintBindingsTo:aDictionary language:languageOrNil.
5968
4832ed93f0b4 preps for timeZone
Claus Gittinger <cg@exept.de>
parents: 5964
diff changeset
  1722
    zone := self timeZoneName.
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
  1723
    tzDelta := self timeZoneDeltaInMinutes.
4844
6938f0df31f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4841
diff changeset
  1724
6419
5cf00f5e656d more ANSI compatibility
Claus Gittinger <cg@exept.de>
parents: 6172
diff changeset
  1725
    ampm := self meridianAbbreviation.
16829
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1726
    usHours := self hour12 printString.
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1727
    aDictionary at:$U put:usHours.
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1728
    aDictionary at:$u put:(usHours leftPaddedTo:2 with:$0).
14493
0a3c9081d40a changed: #addPrintBindingsTo:language:
Claus Gittinger <cg@exept.de>
parents: 13701
diff changeset
  1729
0a3c9081d40a changed: #addPrintBindingsTo:language:
Claus Gittinger <cg@exept.de>
parents: 13701
diff changeset
  1730
12662
a19b835e49a0 changed: #addPrintBindingsTo:language:
sr
parents: 12660
diff changeset
  1731
    aDictionary at:$a put:ampm.
a19b835e49a0 changed: #addPrintBindingsTo:language:
sr
parents: 12660
diff changeset
  1732
    aDictionary at:$A put:ampm asUppercase.
a19b835e49a0 changed: #addPrintBindingsTo:language:
sr
parents: 12660
diff changeset
  1733
    aDictionary at:$z put:zone.
a19b835e49a0 changed: #addPrintBindingsTo:language:
sr
parents: 12660
diff changeset
  1734
    aDictionary at:$Z put:zone asUppercase.
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
  1735
9432
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
  1736
    tzDelta == 0 ifTrue:[
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
  1737
        s := 'Z'.
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
  1738
    ] ifFalse:[
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
  1739
        s := tzDelta < 0 ifTrue:[ '-' ] ifFalse:[ '+' ].
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
  1740
        tzDelta := tzDelta abs.
20200
5259d691c97e #OTHER by mawalch
mawalch
parents: 19894
diff changeset
  1741
        s := s  , ((tzDelta // 60) printStringLeftPaddedTo:2 with:$0),
9432
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
  1742
            ':' , ((tzDelta \\ 60) printStringLeftPaddedTo:2 with:$0).
79e9c3e9bb75 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 9429
diff changeset
  1743
    ].
6172
a3c88ea5efe9 comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents: 6048
diff changeset
  1744
    aDictionary at:#TZD put:s
13082
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1745
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1746
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1747
    "
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1748
      |dict|
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1749
      dict := Dictionary new.
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1750
      Timestamp now addPrintBindingsTo:dict language:#en.
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1751
      dict inspect
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1752
    "
4844
6938f0df31f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4841
diff changeset
  1753
!
6938f0df31f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4841
diff changeset
  1754
23020
5c413c4c1188 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22995
diff changeset
  1755
printIso8601CompressedOn:aStream
5c413c4c1188 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22995
diff changeset
  1756
    self subclassResponsibility
5c413c4c1188 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22995
diff changeset
  1757
5c413c4c1188 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22995
diff changeset
  1758
    "
5c413c4c1188 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22995
diff changeset
  1759
     Timestamp now printStringIso8601       -> '2018-05-09T12:15:53.279'
5c413c4c1188 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22995
diff changeset
  1760
     Time now printStringIso8601            -> 'T16:27:08'
5c413c4c1188 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22995
diff changeset
  1761
     Date today printStringIso8601          -> '2018-05-09'
5c413c4c1188 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22995
diff changeset
  1762
5c413c4c1188 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22995
diff changeset
  1763
     Timestamp now printStringIso8601Compressed       -> '20180525T120822.699'
5c413c4c1188 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22995
diff changeset
  1764
     Time now printStringIso8601Compressed            -> 'T120837'
5c413c4c1188 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22995
diff changeset
  1765
     Date today printStringIso8601Compressed          -> '20180525'
5c413c4c1188 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22995
diff changeset
  1766
    "
5c413c4c1188 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22995
diff changeset
  1767
5c413c4c1188 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22995
diff changeset
  1768
    "Created: / 25-05-2018 / 12:08:07 / Claus Gittinger"
5c413c4c1188 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22995
diff changeset
  1769
!
5c413c4c1188 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22995
diff changeset
  1770
22826
ec2526db594c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22632
diff changeset
  1771
printIso8601FormatOn:aStream
ec2526db594c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22632
diff changeset
  1772
    self subclassResponsibility
ec2526db594c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22632
diff changeset
  1773
ec2526db594c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22632
diff changeset
  1774
    "
22838
5e61e62bd48a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22836
diff changeset
  1775
     Timestamp now printStringIso8601       -> '2018-05-09T12:15:53.279+02'
5e61e62bd48a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22836
diff changeset
  1776
     Time now printStringIso8601            -> 'T16:27:08'
5e61e62bd48a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22836
diff changeset
  1777
     Date today printStringIso8601          -> '2018-05-09'
22826
ec2526db594c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22632
diff changeset
  1778
    "
ec2526db594c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22632
diff changeset
  1779
!
ec2526db594c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22632
diff changeset
  1780
4649
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1781
printOn:aStream format:aFormatString
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1782
    "print using a format string;
13175
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1783
     See #addPrintBindingsTo:language: for allowed format strings"
7327
ab17eb5f11a6 printFormat
Claus Gittinger <cg@exept.de>
parents: 7294
diff changeset
  1784
13175
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1785
    self printOn:aStream format:aFormatString language:nil.
10907
8b98ba82a46f Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents: 10770
diff changeset
  1786
8b98ba82a46f Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents: 10770
diff changeset
  1787
    "
8b98ba82a46f Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents: 10770
diff changeset
  1788
     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
  1789
     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
  1790
     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
  1791
     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
  1792
     Time now printOn:Transcript format:'%h:%m'      . Transcript cr. 
8b98ba82a46f Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents: 10770
diff changeset
  1793
     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
  1794
     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
  1795
    "
8b98ba82a46f Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents: 10770
diff changeset
  1796
8b98ba82a46f Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents: 10770
diff changeset
  1797
    "Modified: 22.2.1996 / 16:58:30 / cg"
8b98ba82a46f Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents: 10770
diff changeset
  1798
!
8b98ba82a46f Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents: 10770
diff changeset
  1799
13082
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1800
printOn:aStream format:aFormatString language:languageString
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1801
    "print using a format string;
13175
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1802
     See #addPrintBindingsTo:language: for allowed format strings"
13082
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1803
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1804
    |dict|
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1805
23602
fcf3d6f2f944 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23235
diff changeset
  1806
"/ is this a good idea?    
fcf3d6f2f944 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23235
diff changeset
  1807
"/    aFormatString = '%h:%m:%s' ifTrue:[
fcf3d6f2f944 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23235
diff changeset
  1808
"/        "/ this is so common...
fcf3d6f2f944 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23235
diff changeset
  1809
"/        aStream nextPutAll:(self hours printStringLeftPaddedTo:2 with:$0).
fcf3d6f2f944 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23235
diff changeset
  1810
"/        aStream nextPutAll:':'.
fcf3d6f2f944 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23235
diff changeset
  1811
"/        aStream nextPutAll:(self minutes printStringLeftPaddedTo:2 with:$0).
fcf3d6f2f944 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23235
diff changeset
  1812
"/        aStream nextPutAll:':'.
fcf3d6f2f944 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23235
diff changeset
  1813
"/        aStream nextPutAll:(self seconds printStringLeftPaddedTo:2 with:$0).
fcf3d6f2f944 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23235
diff changeset
  1814
"/        ^ self 
fcf3d6f2f944 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23235
diff changeset
  1815
"/    ].
fcf3d6f2f944 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23235
diff changeset
  1816
    
13082
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1817
    dict := IdentityDictionary new.
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1818
    self addPrintBindingsTo:dict language:languageString.
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1819
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1820
    aFormatString expandPlaceholdersWith:dict on:aStream
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1821
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1822
    "
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1823
     Timestamp now printOn:Transcript format:'%h:%m:%s'   . Transcript cr.      
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1824
     Time now printOn:Transcript format:'%h:%m:%s'   . Transcript cr.      
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1825
     Time now printOn:Transcript format:'%H:%m:%s'   . Transcript cr.      
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1826
     Time now printOn:Transcript format:'%u:%m:%s %a'. Transcript cr.   
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1827
     Time now printOn:Transcript format:'%h:%m'      . Transcript cr. 
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1828
     Time now printOn:Transcript format:'%H:%m %A'   . Transcript cr.
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1829
     Time now printOn:Transcript format:'minutes:%M seconds:%S'. Transcript cr.
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1830
    "
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1831
23602
fcf3d6f2f944 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23235
diff changeset
  1832
    "Modified: / 22-02-1996 / 16:58:30 / cg"
fcf3d6f2f944 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23235
diff changeset
  1833
    "Modified: / 14-01-2019 / 18:22:12 / Claus Gittinger"
13082
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1834
!
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1835
10907
8b98ba82a46f Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents: 10770
diff changeset
  1836
printStringFormat:aFormatString
13175
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1837
    "print using a format string.
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1838
     See #addPrintBindingsTo:language: for allowed format strings"
10907
8b98ba82a46f Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents: 10770
diff changeset
  1839
13175
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1840
    ^ self printStringFormat:aFormatString language:nil.
4649
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1841
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1842
    "
17400
2aad82c1d66c class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 17195
diff changeset
  1843
     Timestamp now printStringFormat:'%U:%m:%s %a'        
2aad82c1d66c class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 17195
diff changeset
  1844
     Timestamp now printStringFormat:'%u:%m:%s %a'        
4649
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1845
     Time now printStringFormat:'%U:%m:%s %a'   
17400
2aad82c1d66c class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 17195
diff changeset
  1846
     Time now printStringFormat:'%u:%m:%s %a'   
4649
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1847
4844
6938f0df31f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4841
diff changeset
  1848
     Time now printStringFormat:'%h:%m:%s'      
4649
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1849
     Time now printStringFormat:'%H:%m:%s'      
4844
6938f0df31f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4841
diff changeset
  1850
     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
  1851
     Timestamp now printStringFormat:'%H:%m:%s.%i'   
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
  1852
     Timestamp now printStringFormat:'%H:%m:%s.%(milli1)'   
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
  1853
     Timestamp now printStringFormat:'%H:%m:%s.%(milli2)'     
4c3d944ef85a Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 8244
diff changeset
  1854
     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
  1855
     Timestamp now printStringFormat:'%(day)-%(monthName)-%(year) :%m:%s'       
4649
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1856
     Time now printStringFormat:'%u:%m:%s %a'   
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1857
     Time now printStringFormat:'%h:%m'         
4844
6938f0df31f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4841
diff changeset
  1858
     Time now printStringFormat:'%h:%m'         
4649
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1859
     Time now printStringFormat:'%H:%m %A'     
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1860
     Time now printStringFormat:'%m minutes after %U %a'     
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1861
     Time now printStringFormat:'%t seconds after %U %a'     
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1862
     Time now printStringFormat:'%T seconds from midNight'     
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1863
    "
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1864
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1865
    "Modified: 22.2.1996 / 16:58:30 / cg"
13082
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1866
!
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1867
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1868
printStringFormat:aFormatString language:languageString
13175
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1869
    "print using a format string.
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1870
     See #addPrintBindingsTo:language: for allowed format strings"
13082
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1871
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1872
    |s|
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1873
16829
2b434f626099 class: AbstractTime
Stefan Vogel <sv@exept.de>
parents: 16673
diff changeset
  1874
    s := CharacterWriteStream on:(String new:20).
13082
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1875
    self printOn:s format:aFormatString language:languageString.
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1876
    ^ s contents.
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1877
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1878
    "
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1879
     Timestamp now printStringFormat:'%U:%m:%s %a  
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1880
     Time now printStringFormat:'%U:%m:%s %a'   
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1881
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1882
     Time now printStringFormat:'%h:%m:%s'      
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1883
     Time now printStringFormat:'%H:%m:%s'      
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1884
     Time now printStringFormat:'%H:%m:%s.%i'           
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1885
     Timestamp now printStringFormat:'%H:%m:%s.%i'   
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1886
     Timestamp now printStringFormat:'%H:%m:%s.%(milli1)'   
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1887
     Timestamp now printStringFormat:'%H:%m:%s.%(milli2)'     
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1888
     Timestamp now printStringFormat:'%(day)-%(month)-%(year) :%m:%s'       
13175
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1889
     Timestamp now printStringFormat:'%(day)-%(monthName)-%(year) :%m:%s' language:#en      
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1890
     Timestamp now printStringFormat:'%(day)-%(monthName)-%(year) :%m:%s' language:#de      
ea7102cce519 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 13082
diff changeset
  1891
     Timestamp now printStringFormat:'%(day)-%(monthName)-%(year) :%m:%s' language:#fr      
13082
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1892
     Time now printStringFormat:'%u:%m:%s %a'   
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1893
     Time now printStringFormat:'%h:%m'         
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1894
     Time now printStringFormat:'%h:%m'         
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1895
     Time now printStringFormat:'%H:%m %A'     
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1896
     Time now printStringFormat:'%m minutes after %U %a'     
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1897
     Time now printStringFormat:'%t seconds after %U %a'     
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1898
     Time now printStringFormat:'%T seconds from midNight'     
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1899
    "
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1900
Stefan Vogel <sv@exept.de>
parents: 13026
diff changeset
  1901
    "Modified: 22.2.1996 / 16:58:30 / cg"
22826
ec2526db594c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22632
diff changeset
  1902
!
ec2526db594c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22632
diff changeset
  1903
22836
1c878b36a068 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22826
diff changeset
  1904
printStringIso8601
22826
ec2526db594c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22632
diff changeset
  1905
    "return the Iso8601 representation of the receiver with local timezon information.
ec2526db594c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22632
diff changeset
  1906
     This format looks like:
22836
1c878b36a068 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22826
diff changeset
  1907
        1999-01-01T24:00:00
22826
ec2526db594c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22632
diff changeset
  1908
     or, for zero hr:min:sec,
22836
1c878b36a068 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22826
diff changeset
  1909
        1999-01-01
22826
ec2526db594c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22632
diff changeset
  1910
     Of course, a 24 hour clock is used."
ec2526db594c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22632
diff changeset
  1911
ec2526db594c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22632
diff changeset
  1912
    ^ String streamContents:[:s | self printIso8601FormatOn:s]
ec2526db594c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22632
diff changeset
  1913
ec2526db594c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22632
diff changeset
  1914
    "
23020
5c413c4c1188 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22995
diff changeset
  1915
     Timestamp now printStringIso8601
22826
ec2526db594c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22632
diff changeset
  1916
    "
23020
5c413c4c1188 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22995
diff changeset
  1917
5c413c4c1188 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22995
diff changeset
  1918
    "Modified (comment): / 25-05-2018 / 11:58:37 / Claus Gittinger"
5c413c4c1188 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22995
diff changeset
  1919
!
5c413c4c1188 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22995
diff changeset
  1920
5c413c4c1188 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22995
diff changeset
  1921
printStringIso8601Compressed
5c413c4c1188 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22995
diff changeset
  1922
    "return the Iso8601 representation of the receiver with local timezon information.
5c413c4c1188 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22995
diff changeset
  1923
     This format looks like:
5c413c4c1188 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22995
diff changeset
  1924
        1999-01-01T24:00:00
5c413c4c1188 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22995
diff changeset
  1925
     or, for zero hr:min:sec,
5c413c4c1188 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22995
diff changeset
  1926
        1999-01-01
5c413c4c1188 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22995
diff changeset
  1927
     Of course, a 24 hour clock is used."
5c413c4c1188 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22995
diff changeset
  1928
5c413c4c1188 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22995
diff changeset
  1929
    ^ String streamContents:[:s | self printIso8601CompressedOn:s]
5c413c4c1188 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22995
diff changeset
  1930
5c413c4c1188 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22995
diff changeset
  1931
    "
5c413c4c1188 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22995
diff changeset
  1932
     Timestamp now printStringIso8601Compressed
5c413c4c1188 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22995
diff changeset
  1933
    "
5c413c4c1188 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22995
diff changeset
  1934
5c413c4c1188 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22995
diff changeset
  1935
    "Created: / 25-05-2018 / 11:58:29 / Claus Gittinger"
22836
1c878b36a068 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22826
diff changeset
  1936
!
1c878b36a068 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22826
diff changeset
  1937
1c878b36a068 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22826
diff changeset
  1938
printStringIso8601Format
22925
9748ba089af4 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22913
diff changeset
  1939
    "would like to make it obsolete, but it is:"
9748ba089af4 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22913
diff changeset
  1940
    <resource: #EXPECCO_API>
9748ba089af4 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22913
diff changeset
  1941
    "<resource: #obsolete>"
22836
1c878b36a068 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22826
diff changeset
  1942
1c878b36a068 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22826
diff changeset
  1943
    "return the Iso8601 representation of the receiver with local timezon information.
1c878b36a068 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22826
diff changeset
  1944
     This format looks like:
1c878b36a068 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22826
diff changeset
  1945
        1999-01-01T24:00:00
1c878b36a068 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22826
diff changeset
  1946
     or, for zero hr:min:sec,
1c878b36a068 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22826
diff changeset
  1947
        1999-01-01
1c878b36a068 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22826
diff changeset
  1948
     Of course, a 24 hour clock is used."
1c878b36a068 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22826
diff changeset
  1949
22925
9748ba089af4 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22913
diff changeset
  1950
    "/ self obsoleteMethodWarning:'use printStringIso8601'.
22836
1c878b36a068 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22826
diff changeset
  1951
    ^ self printStringIso8601
1c878b36a068 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22826
diff changeset
  1952
1c878b36a068 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22826
diff changeset
  1953
    "
1c878b36a068 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22826
diff changeset
  1954
     Timestamp now printStringIso8601Format
1c878b36a068 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22826
diff changeset
  1955
    "
4649
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1956
! !
3eaf75dd8973 Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents: 3476
diff changeset
  1957
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1958
!AbstractTime methodsFor:'private'!
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
  1959
22836
1c878b36a068 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22826
diff changeset
  1960
additionalPicoseconds
1c878b36a068 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22826
diff changeset
  1961
    "return the additional picoseconds within the current second (0..999999999).
1c878b36a068 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22826
diff changeset
  1962
     Here, assume that we have none"
1c878b36a068 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22826
diff changeset
  1963
1c878b36a068 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22826
diff changeset
  1964
    ^ 0.
1c878b36a068 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22826
diff changeset
  1965
1c878b36a068 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22826
diff changeset
  1966
    "
1c878b36a068 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22826
diff changeset
  1967
     Timestamp now picoseconds
1c878b36a068 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22826
diff changeset
  1968
    "
1c878b36a068 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22826
diff changeset
  1969
!
1c878b36a068 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22826
diff changeset
  1970
1500
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1971
fromOSTime:osTime
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1972
    "set my time, from operatingSystems time parts"
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
  1973
1500
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1974
    ^ self subclassResponsibility
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1975
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1976
    "Modified: 1.7.1996 / 15:09:44 / cg"
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
  1977
!
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
  1978
22618
96964b12a929 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22283
diff changeset
  1979
fromOSTimeWithMilliseconds:anUninterpretedOSTime
96964b12a929 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22283
diff changeset
  1980
    "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
  1981
96964b12a929 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22283
diff changeset
  1982
    self subclassResponsibility
96964b12a929 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22283
diff changeset
  1983
!
96964b12a929 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22283
diff changeset
  1984
22945
c6f530d70280 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22925
diff changeset
  1985
getMicroseconds
c6f530d70280 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22925
diff changeset
  1986
    "get the milliseconds since some point of time in the past.    
c6f530d70280 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22925
diff changeset
  1987
     Since I am abstract (not knowing how the time is actually
c6f530d70280 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22925
diff changeset
  1988
     represented), this must be done by a concrete class.
c6f530d70280 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22925
diff changeset
  1989
     Also be aware that the returned value is concrete-class specific;
c6f530d70280 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22925
diff changeset
  1990
     Time returns the micros since midnight, Timestamp since the epoch.
c6f530d70280 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22925
diff changeset
  1991
     Use this only to compute relative time deltas.
c6f530d70280 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22925
diff changeset
  1992
     Here is a fallback, which only returns milliseocnd precision values"
c6f530d70280 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22925
diff changeset
  1993
c6f530d70280 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22925
diff changeset
  1994
    ^ self getMilliseconds * 1000
c6f530d70280 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22925
diff changeset
  1995
!
c6f530d70280 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22925
diff changeset
  1996
1500
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1997
getMilliseconds
8200
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
  1998
    "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
  1999
     Since I am abstract (not knowing how the time is actually
22836
1c878b36a068 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22826
diff changeset
  2000
     represented), this must be done by a concrete class.
1c878b36a068 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22826
diff changeset
  2001
     Also be aware that the returned value is concrete-class specific;
1c878b36a068 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22826
diff changeset
  2002
     Time returns the millis since midnight, Timestamp since the epoch.
1c878b36a068 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22826
diff changeset
  2003
     Use this only to compute relative time deltas."
1500
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  2004
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  2005
    ^ self subclassResponsibility
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  2006
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  2007
    "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
  2008
!
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  2009
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2010
getSeconds
22283
3edefecbb6b6 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22036
diff changeset
  2011
    "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
  2012
     Since I am abstract (not knowing how the time is actually
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2013
     represented), this must be done by a concrete class."
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
  2014
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2015
    ^ self subclassResponsibility
22283
3edefecbb6b6 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22036
diff changeset
  2016
3edefecbb6b6 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22036
diff changeset
  2017
    "Modified (comment): / 21-09-2017 / 18:50:30 / cg"
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2018
!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2019
1500
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  2020
setMilliseconds:millis
8200
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
  2021
    "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
  2022
     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
  2023
     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
  2024
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  2025
    ^ self subclassResponsibility
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  2026
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  2027
    "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
  2028
!
d42e61e53cee changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  2029
23235
acf3d6e991aa #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23020
diff changeset
  2030
setMilliseconds:arg1 additionalPicoseconds:arg2
acf3d6e991aa #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23020
diff changeset
  2031
    "raise an error: must be redefined in concrete subclass(es)"
acf3d6e991aa #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23020
diff changeset
  2032
acf3d6e991aa #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23020
diff changeset
  2033
    ^ self subclassResponsibility
acf3d6e991aa #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23020
diff changeset
  2034
!
acf3d6e991aa #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23020
diff changeset
  2035
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2036
setSeconds:secs
8200
d443d3c8ce40 More arithmethic.
Stefan Vogel <sv@exept.de>
parents: 8111
diff changeset
  2037
    "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
  2038
     Since I am abstract (not knowing how the time is actually
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2039
     represented), this must be done by a concrete class."
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2040
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2041
    ^ self subclassResponsibility
17015
f7c4867a3633 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16982
diff changeset
  2042
!
f7c4867a3633 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16982
diff changeset
  2043
f7c4867a3633 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16982
diff changeset
  2044
speciesNew
f7c4867a3633 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 16982
diff changeset
  2045
    ^ self species basicNew
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
  2046
! !
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
  2047
2310
2cb1366e0eb3 Correct name: #secondDay --> #secondInDay.
Stefan Vogel <sv@exept.de>
parents: 1500
diff changeset
  2048
!AbstractTime class methodsFor:'documentation'!
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
  2049
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  2050
version
18918
ea95a7e73213 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18454
diff changeset
  2051
    ^ '$Header$'
12660
518ee2523071 changed: #addPrintBindingsTo:language:
sr
parents: 12002
diff changeset
  2052
!
518ee2523071 changed: #addPrintBindingsTo:language:
sr
parents: 12002
diff changeset
  2053
518ee2523071 changed: #addPrintBindingsTo:language:
sr
parents: 12002
diff changeset
  2054
version_CVS
18918
ea95a7e73213 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18454
diff changeset
  2055
    ^ '$Header$'
240
f5ff68fffb92 Initial revision
claus
parents:
diff changeset
  2056
! !
15684
4c4bc53e32c8 class: AbstractTime
Claus Gittinger <cg@exept.de>
parents: 14494
diff changeset
  2057