|
|
Class: AbstractTime
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
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.
Time
Date
Timestamp
Delay
ProcessorScheduler
Compatibility-Squeak
-
dateAndTimeFromSeconds: secondCount
-
set date and time from seconds since 1901-01-01 00:00 UTC
-
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.
-
millisecondsSince: lastTime
-
Answer the elapsed time since last recorded in milliseconds.
Compensate for rollover.
-
primSecondsClock
-
returns the number of seconds since 1.1.1901 UTC
Compatibility-VW
-
totalSeconds
-
returns the number of seconds since 1.1.1901 UTC
error handling
-
conversionErrorSignal
-
return the signal used for conversion error handling
instance creation
-
dateAndTimeNow
-
return an array filled with the current date and time.
See also: Date today / Time now / Timestamp now.
-
epoch
-
answer the time when we start counting
-
now
-
return an instance of myself representing this moment.
private-instance creation
-
fromOSTime: osTime
-
return a time, representing the time given by the operatingSystem time.
Not meant for public use.
-
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
-
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.
-
secondClock
-
return seconds of now - for GNU-ST compatibility
timing evaluations
-
microsecondsToRun: aBlock
-
evaluate the argument, aBlock; return the number of milliseconds it took
-
millisecondsToRun: aBlock
-
evaluate the argument, aBlock; return the number of milliseconds it took
-
secondsToRun: aBlock
-
evaluate the argument, aBlock; return the number of seconds it took
Compatibility-ANSI
-
hour12
-
return the hour (1..12).
-
hour24
-
return the hour (0..23).
-
meridianAbbreviation
-
am/pm
Javascript support
-
getDate
-
return the day of the month (1..31)
-
getDay
-
return the day of the week (0..6); Sunday is 0
-
getFullYear
-
return the year
-
getHours
-
return the hours (0..24)
-
getMinutes
-
return the minutes (0..60)
-
getMonth
-
return the day of the month (1..12)
-
js_add: aNumber
-
For JavaScript only:
Generated for +-operator in javascript.
-
js_getMilliseconds
-
return the millieconds (0..999)
-
js_getSeconds
-
return the seconds (0..60)
abstract
-
hours
-
return the hour of time (0..23)
** This method raises an error - it must be redefined in concrete classes **
-
milliseconds
-
return the milliseconds since the start of the second (0..999)
** This method raises an error - it must be redefined in concrete classes **
-
minutes
-
return the minutes since the start of the hour (0..59)
** This method raises an error - it must be redefined in concrete classes **
-
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
-
hourInDay
-
return the hours (0..23)
-
minuteInDay
-
return the minutes (0..59)
-
secondInDay
-
return the seconds (0..59)
-
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.
-
timeZoneName
-
-
weekInYear
-
return the week number of the receiver - 1 for Jan, 1st.
arithmetic
-
+ aNumberOrTimeDuration
-
Add aNumber numberOfSeconds or, if its a timeDuration, add its value
-
- aTimeOrNumberOfSeconds
-
return the delta in seconds between 2 times or subtract a number of seconds.
-
addDays: numberOfDays
-
return a new instance of myself, numberOfDays afterwards.
-
addHours: numberOfHours
-
return a new instance of myself, numberOfHours afterwards.
-
addMilliseconds: numberOfMilliSeconds
-
return a new instance of myself, numberOfMilliSeconds afterwards.
-
addMinutes: numberOfMinutes
-
return a new instance of myself, numberOfMinutes afterwards.
-
addSeconds: numberOfSeconds
-
return a new instance of myself, numberOfSeconds afterwards.
-
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
-
subtractDays: numberOfDays
-
return a new instance of myself, numberOfDays before.
-
subtractHours: numberOfHours
-
return a new instance of myself, numberOfHours before.
-
subtractMilliseconds: numberOfMilliSeconds
-
return a new instance of myself, numberOfMilliSeconds before.
-
subtractMinutes: numberOfMinutes
-
return a new instance of myself, numberOfMinutes before.
-
subtractSeconds: numberOfSeconds
-
return a new instance of myself, numberOfSeconds before.
-
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
-
< aTime
-
return true if the receiver is before the argument
-
> aTime
-
return true if the receiver is after the argument
converting
-
asAbsoluteTime
-
deprecated, use #asTimestamp
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
asTimestamp
-
** This method raises an error - it must be redefined in concrete classes **
double dispatching
-
differenceFromTimestamp: aTimestamp
-
printing & storing
-
addPrintBindingsTo: aDictionary
-
private print support: add bindings for printing to aDictionary.
-
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)'
-
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)'
-
printStringFormat: aFormatString
-
print using a format string - see #printOn:format:
private
-
fromOSTime: osTime
-
set my time, from operatingSystems time parts
** This method raises an error - it must be redefined in concrete classes **
-
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 **
-
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 **
-
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 **
-
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 **
|