eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'AbstractTime':

Home

everywhere
www.exept.de
for:
[back]

Class: AbstractTime


Inheritance:

   Object
   |
   +--Magnitude
      |
      +--AbstractTime
         |
         +--Time
         |
         +--Timestamp

Package:
stx:libbasic
Category:
Magnitude-Time
Version:
rev: 1.68 date: 2010/03/31 13:52:36
user: stefan
file: AbstractTime.st directory: libbasic
module: stx stc-classLibrary: libbasic
Author:
Claus Gittinger

Description:


This is an abstract class providing common protocol for Time (time in day)
and Timestamp (time plus day).
There are no instances of this class in the system.
It is meant as a home for methods common to time handling classes.


Related information:

    Time
    Date
    Timestamp
    Delay
    ProcessorScheduler

Class protocol:

Compatibility-Squeak
o  dateAndTimeFromSeconds: secondCount
set date and time from seconds since 1901-01-01 00:00 UTC

o  milliseconds: msTime1 since: msTime2
return the number of milliseconds between two
millisecond time values, compensating for roll-over.
The same as millisecondsBetween:and: for Squeak compatibility.

o  millisecondsSince: lastTime
Answer the elapsed time since last recorded in milliseconds.
Compensate for rollover.

o  primSecondsClock
returns the number of seconds since 1.1.1901 UTC

Compatibility-VW
o  totalSeconds
returns the number of seconds since 1.1.1901 UTC

error handling
o  conversionErrorSignal
return the signal used for conversion error handling

instance creation
o  dateAndTimeNow
return an array filled with the current date and time.
See also: Date today / Time now / Timestamp now.

o  epoch
answer the time when we start counting

o  now
return an instance of myself representing this moment.

private-instance creation
o  fromOSTime: osTime
return a time, representing the time given by the operatingSystem time.
Not meant for public use.

o  fromSeconds: seconds
return an instance that is constructed from seconds.
This method is only allowed for second values as returned by
getSeconds, possibly adding/subtracting to that.
Never depend on any specific interpretation of the seconds,
since it depends on how the OperatingSystem counts time
(some start at 1900, others with 1970 ...)

queries
o  millisecondClockValue
return the millisecond clock - since this one overruns
regularly, use the value only for short timing deltas.
Also remember that it wraps when comparing these values.

o  secondClock
return seconds of now - for GNU-ST compatibility

timing evaluations
o  microsecondsToRun: aBlock
evaluate the argument, aBlock; return the number of milliseconds it took

o  millisecondsToRun: aBlock
evaluate the argument, aBlock; return the number of milliseconds it took

o  secondsToRun: aBlock
evaluate the argument, aBlock; return the number of seconds it took


Instance protocol:

Compatibility-ANSI
o  hour12
return the hour (1..12).

o  hour24
return the hour (0..23).

o  meridianAbbreviation
am/pm

Javascript support
o  getDate
return the day of the month (1..31)

o  getDay
return the day of the week (0..6); Sunday is 0

o  getFullYear
return the year

o  getHours
return the hours (0..24)

o  getMinutes
return the minutes (0..60)

o  getMonth
return the day of the month (1..12)

o  js_add: aNumber
For JavaScript only:
Generated for +-operator in javascript.

o  js_getMilliseconds
return the millieconds (0..999)

o  js_getSeconds
return the seconds (0..60)

abstract
o  hours
return the hour of time (0..23)

** This method raises an error - it must be redefined in concrete classes **

o  milliseconds
return the milliseconds since the start of the second (0..999)

** This method raises an error - it must be redefined in concrete classes **

o  minutes
return the minutes since the start of the hour (0..59)

** This method raises an error - it must be redefined in concrete classes **

o  seconds
return the seconds since the start of the minute (0..59)

** This method raises an error - it must be redefined in concrete classes **

accessing
o  hourInDay
return the hours (0..23)

o  minuteInDay
return the minutes (0..59)

o  secondInDay
return the seconds (0..59)

o  timeZoneDeltaInMinutes
answer the number of minutes between local time and utc time.
Delta is positive if local time is ahead of utc, negative if behind utc.

o  timeZoneName

o  weekInYear
return the week number of the receiver - 1 for Jan, 1st.

arithmetic
o  + aNumberOrTimeDuration
Add aNumber numberOfSeconds or, if its a timeDuration, add its value

o  - aTimeOrNumberOfSeconds
return the delta in seconds between 2 times or subtract a number of seconds.

o  addDays: numberOfDays
return a new instance of myself, numberOfDays afterwards.

o  addHours: numberOfHours
return a new instance of myself, numberOfHours afterwards.

o  addMilliseconds: numberOfMilliSeconds
return a new instance of myself, numberOfMilliSeconds afterwards.

o  addMinutes: numberOfMinutes
return a new instance of myself, numberOfMinutes afterwards.

o  addSeconds: numberOfSeconds
return a new instance of myself, numberOfSeconds afterwards.

o  addTime: timeAmount
return a new instance of myself, timeAmount seconds afterwards.
Provided for ST-80 compatibility.
WARNING:
AddTime is a bad name - it does not add a time, but expects
a numberOfSeconds as argument.
Use any of addSeconds/addHours etc. to make things clear

o  subtractDays: numberOfDays
return a new instance of myself, numberOfDays before.

o  subtractHours: numberOfHours
return a new instance of myself, numberOfHours before.

o  subtractMilliseconds: numberOfMilliSeconds
return a new instance of myself, numberOfMilliSeconds before.

o  subtractMinutes: numberOfMinutes
return a new instance of myself, numberOfMinutes before.

o  subtractSeconds: numberOfSeconds
return a new instance of myself, numberOfSeconds before.

o  subtractTime: timeAmount
return a new instance of myself, timeAmount seconds before myself.
Provided for ST-80 compatibility.
WARNING:
SubtractTime is a bad name - it does not add a time, but expects
a numberOfSeconds as argument.
Use any of addSeconds/addHours etc. to make things clear

comparing
o  < aTime
return true if the receiver is before the argument

o  > aTime
return true if the receiver is after the argument

converting
o  asAbsoluteTime
deprecated, use #asTimestamp

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  asTimestamp

** This method raises an error - it must be redefined in concrete classes **

double dispatching
o  differenceFromTimestamp: aTimestamp

printing & storing
o  addPrintBindingsTo: aDictionary
private print support: add bindings for printing to aDictionary.

o  addPrintBindingsTo: aDictionary language: languageOrNil
private print support: add bindings for printing to aDictionary.
languageOrNil can only be #en or nil for the current language.
bindings:
%h hours, 00..23 (i.e. european) 0-padded to length 2
%u hours, 00..12 (i.e. us) 0-padded to length 2
%m minutes, 00..59 0-padded to length 2
%s seconds, 00..59 0-padded to length 2
%i milliseconds, 000..999 0-padded to length 3
%a am/pm

Timestamp only:
%(day) day, 00..31 0-padded to length 2
%(month) month, 00..12 0-padded to length 2
%(year) year, 4 digits 0-padded to length 4

special:
%H 24-hours - unpadded
%U 12-hours - unpadded
%M minutes - unpadded
%S seconds - unpadded
%I milliseconds, unpadded
%A AM/PM - uppercase

%t seconds within hour (unpadded)
%T seconds from midNight (unpadded)

%(TZD) timeZone delta from UTC in the format +/-hh:mm

%milli1 milliseconds, truncated to 1/10th of a second 0..9
%milli2 milliseconds, truncated to 1/100th of a second 00..99 0-padded to length 2

%nth - counting day-in-month (1->'st'; 2->'nd'; 3->'rd'; 4...->'th')
%weekDayNth - counting day-in-week (1->'st'; 2->'nd'; 3->'rd'; 4...->'th')
%weekNth - counting week-in-year (1->'st'; 2->'nd'; 3->'rd'; 4...->'th')

Timestamp only:
%Day day - unpadded
%Month month - unpadded
%(yearOrTime) year or time 5 digits as in unix-ls:
year if it is not the current year;
time otherwise


The ISO8601 printString are generated with:

Year:
YYYY (eg 1997)
Date today printStringFormat:'%(year)'
Timestamp now printStringFormat:'%(year)'

Year and month:
YYYY-MM (eg 1997-07)
Date today printStringFormat:'%(year)-%(month)'
Timestamp now printStringFormat:'%(year)-%(month)'

Complete date:
YYYY-MM-DD (eg 1997-07-16)
Date today printStringFormat:'%(year)-%(month)-%(day)'
Timestamp now printStringFormat:'%(year)-%(month)-%(day)'

Complete date plus hours and minutes:
YYYY-MM-DDThh:mmTZD (eg 1997-07-16T19:20+01:00)
Timestamp now printStringFormat:'%(year)-%(month)-%(day)T%h:%m%(TZD)'

Complete date plus hours, minutes and seconds:
YYYY-MM-DDThh:mm:ssTZD (eg 1997-07-16T19:20:30+01:00)
Timestamp now printStringFormat:'%(year)-%(month)-%(day)T%h:%m:%s%(TZD)'

Complete date plus hours, minutes, seconds and a decimal fraction of a second
YYYY-MM-DDThh:mm:ss.sTZD (eg 1997-07-16T19:20:30.45+01:00)
Timestamp now printStringFormat:'%(year)-%(month)-%(day)T%h:%m:%s.%(milli2)%(TZD)'


o  printOn: aStream format: aFormatString
print using a format string;
valid format items are:
%h hours, 00..23 (i.e. european) 0-padded to length 2
%u hours, 00..12 (i.e. us) 0-padded to length 2
%m minutes, 00..59 0-padded to length 2
%s seconds, 00..59 0-padded to length 2
%i milliseconds, 000..999 0-padded to length 3
%a am/pm

Timestamp only:
%(day) day, 00..31 0-padded to length 2
%(month) month, 00..12 0-padded to length 2
%(year) year, 4 digits 0-padded to length 4

special:
%H 24-hours - unpadded
%U 12-hours - unpadded
%M minutes - unpadded
%S seconds - unpadded
%I milliseconds, unpadded
%A AM/PM - uppercase

%t seconds within hour (unpadded)
%T seconds from midNight (unpadded)

%(TZD) timeZone delta from UTC in the format +/-hh:mm

%milli1 milliseconds, truncated to 1/10th of a second 0..9
%milli2 milliseconds, truncated to 1/100th of a second 00..99 0-padded to length 2

%nth - counting day-in-month (1->'st'; 2->'nd'; 3->'rd'; 4...->'th')
%weekDayNth - counting day-in-week (1->'st'; 2->'nd'; 3->'rd'; 4...->'th')
%weekNth - counting week-in-year (1->'st'; 2->'nd'; 3->'rd'; 4...->'th')

Timestamp only:
%Day day - unpadded
%Month month - unpadded
%(yearOrTime) year or time 5 digits as in unix-ls:
year if it is not the current year;
time otherwise


The ISO8601 printString are generated with:

Year:
YYYY (eg 1997)
Date today printStringFormat:'%(year)'
Timestamp now printStringFormat:'%(year)'

Year and month:
YYYY-MM (eg 1997-07)
Date today printStringFormat:'%(year)-%(month)'
Timestamp now printStringFormat:'%(year)-%(month)'

Complete date:
YYYY-MM-DD (eg 1997-07-16)
Date today printStringFormat:'%(year)-%(month)-%(day)'
Timestamp now printStringFormat:'%(year)-%(month)-%(day)'

Complete date plus hours and minutes:
YYYY-MM-DDThh:mmTZD (eg 1997-07-16T19:20+01:00)
Timestamp now printStringFormat:'%(year)-%(month)-%(day)T%h:%m%(TZD)'

Complete date plus hours, minutes and seconds:
YYYY-MM-DDThh:mm:ssTZD (eg 1997-07-16T19:20:30+01:00)
Timestamp now printStringFormat:'%(year)-%(month)-%(day)T%h:%m:%s%(TZD)'

Complete date plus hours, minutes, seconds and a decimal fraction of a second
YYYY-MM-DDThh:mm:ss.sTZD (eg 1997-07-16T19:20:30.45+01:00)
Timestamp now printStringFormat:'%(year)-%(month)-%(day)T%h:%m:%s.%(milli2)%(TZD)'


o  printStringFormat: aFormatString
print using a format string - see #printOn:format:

private
o  fromOSTime: osTime
set my time, from operatingSystems time parts

** This method raises an error - it must be redefined in concrete classes **

o  getMilliseconds
get the milliseconds since some point of time in the past.
Since I am abstract (not knowing how the time is actually
represented), this must be done by a concrete class.

** This method raises an error - it must be redefined in concrete classes **

o  getSeconds
get the seconds since some point of time in the past.
Since I am abstract (not knowing how the time is actually
represented), this must be done by a concrete class.

** This method raises an error - it must be redefined in concrete classes **

o  setMilliseconds: millis
set the milliseconds since some point of time in the past.
Since I am abstract (not knowing how the time is actually
represented), this must be done by a concrete class.

** This method raises an error - it must be redefined in concrete classes **

o  setSeconds: secs
set the seconds since some point of time in the past.
Since I am abstract (not knowing how the time is actually
represented), this must be done by a concrete class.

** This method raises an error - it must be redefined in concrete classes **



ST/X 6.1.1; WebServer 1.620 at exept:8081; Wed, 23 May 2012 07:44:11 GMT