eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'Time':

Home

everywhere
www.exept.de
for:
[back]

Class: Time


Inheritance:

   Object
   |
   +--Magnitude
      |
      +--AbstractTime
         |
         +--Time
            |
            +--TimeDuration

Package:
stx:libbasic
Category:
Magnitude-Time
Version:
rev: 1.87 date: 2010/03/31 09:39:45
user: stefan
file: Time.st directory: libbasic
module: stx stc-classLibrary: libbasic
Author:
Claus Gittinger

Description:


Instances of time represent a particular time-of-day.
Since they only store hours, minutes and seconds within a day,
they cannot be used to compare times across midnight 
(i.e. they should not be used as timeStamps).

Use instances of Timestamp (and read the comment there) to do this.

Examples:
    |t|

    t := Time now.
    Transcript showCR:t.


    |t1 t2|

    t1 := Time now.
    (Delay forSeconds:10) wait.
    t2 := Time now.
    t2 - t1   


Related information:

    Date
    Timestamp
    AbstractTime
    OperatingSystem
    Filename

Class protocol:

format strings
o  formatString12us
return the format string used to format US times (and other areas)

o  formatString24
return the format string used to format non US times

instance creation
o  hour: h minute: m
compatibility

o  hour: h minute: m second: s
compatibility

o  hour: h minutes: m seconds: s
return an instance of Time representing the given time.
See also Time now / Date today / Timestamp now.
Obsolete: please use #hours:minutes:seconds:

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

o  hours: h minutes: m seconds: s
return an instance of Time representing the given time.
See also Time now / Date today / Timestamp now.

o  midnight
Answer a new instance at midnight.

o  noon
Answer a new instance at noon.

o  readFrom: aStringOrStream onError: exceptionBlock
return a new Time, reading a printed representation from aStream.
If no am/pm follows the time, the string is interpreted as
either 24 hour format or being am.


Instance protocol:

Compatibility-Squeak
o  intervalString
Treat the time as a difference.
Give it in hours and minutes with two digits of accuracy.

o  print24: prnt24FormatBoolean on: aStream
print me either US or 24hr format on a stream

o  print24: prnt24Format showSeconds: doSeconds on: aStream
print me either US or 24hr format, optionally with
seconds on a stream

accessing
o  hours
return the number of hours since midnight (i.e. 0..23)

o  milliseconds
time does not keep milliseconds
- for compatibility with Timestamp

o  minutes
return the number of minutes within the hour (i.e. 0..59)

o  seconds
return the number of seconds within the minute (i.e. 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.

Time is local time, so answer the delta of today

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

o  = aTime
return true if the argument, aTime represents the same timeOfDay

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

o  hash
return an integer useful for hashing on times

converting
o  asNative

o  asSeconds
return the number of seconds elapsed since midnight

o  asTime
return a Time object from the receiver - thats the receiver.

o  asTimeDuration
return an TimeDuration object from the receiver, taking the time since midnight.

o  asTimestamp
return an Timestamp object from the receiver.
The date components are taken from today.

printing & storing
o  print12HourFormatOn: aStream
append a human readable printed representation of the receiver to aStream.
Format is hh:mm:ss am/pm (i.e. 12-hour american format).

o  print24HourFormatOn: aStream
append a human readable printed representation of the receiver to aStream.
Format is hh:mm:ss (i.e. 24-hour european format).

o  printOn: aStream
append a human readable printed representation of the receiver to aStream.
The format is suitable for a human - not meant to be read back.

Format is hh:mm:ss either in 12-hour or 24-hour format.
depending on the setting of LanguageTerritory.
I dont know what ST-80 does here (12-hour format ?)

o  printString12HourFormat
return a printed representation in 12 hour format

o  printString24HourFormat
return a printed representation in 24 hour format

o  shortPrintString
dummy - for now

private
o  fromOSTime: osTime
set my time, given an osTime

o  getMilliseconds
return the number of milliseconds since midnight

o  getSeconds
return the number of seconds since midnight

o  setHours: h minutes: m seconds: s
set my time given individual values

o  setMilliseconds: millis
set my time given milliseconds since midnight

o  setSeconds: secs
set my time given seconds since midnight.
Notice the modulo operations here - there cannot be a time beyond 24hours
(use TimeDuration, if you need that).

o  timeEncoding
the internal encoding is stricktly private,
and should not be used outside.

o  timeEncoding: encoding
the internal encoding is stricktly private,
and should not be used outside.



ST/X 6.1.1; WebServer 1.620 at exept:8081; Wed, 23 May 2012 21:38:10 GMT