Hamster-Scripts: Functions (built-in)

Time

ticks

Retrieves the number of milliseconds that have elapsed since Windows was started.

Returns: Integer.

$start = ticks
# ...
$stop = ticks
print( "It took ", $stop - $start, "ms." )

time

Retrieves the current date and time (local time).

Returns: Integer (Unix-format, i.e. seconds since Jan 1st 1970).

$now = time
$yesterday = $now - 24*60*60

timegmt

Retrieves the current date and time (GMT).

Returns: Integer (Unix-format, i.e. seconds since Jan 1st 1970).

$nowgmt = timegmt

decodetime( <time>, <yyyy>, <mm>, <dd>, <hh>, <nn>, <ss>, <wd> )

...
decodetime( <time>, <yyyy> )

Decodes the given <time>. Other parameters are ignored, unless they are variables. In this case, the given variable is set to one of the decoded values: <yyyy> (year), <mm> (month), <dd> (day), <hh> (hour), <nn> (minute), <ss> (seconds), <wd> (day of week; 1=Sunday, ..., 7=Saturday).

Returns: <time>

var( $hrs, $min, $sec )
decodetime( time, 0, 0, 0, $hrs, $min, $sec )
print( "Current time: ", $hrs, ":", $min, ":", $sec )

encodetime( <yyyy>, <mm>, <dd>, <hh>, <nn>, <ss> )

Returns a time-value build from the given parameters.

Returns: <time>

encodetime( 2000, 12, 31, 23, 59, 59 )

TimeToRfc( <time>, <format> )

Returns the given local time in selected format. If <time> is omitted, current time is used.
Available <formats> are: 0=RFC format with local timezone (default), 1=RFC format with GMT, 2=only timezone part in RFC format

Returns: empty string on errors, otherwise valid value

MsgSetHeader( $msg, "Date", TimeToRfc( time, 0 ) )

TimeFromRfc( <rfc-time-string> )

Convert the given RFC time string (e. g. value of Date: header) into a time value.

Returns: =0:invalid string, >0: time

$time = TimeFromRfc( MsgGetHeader( $msg, "Date" ) )

[www.elbiah.de Hamster Playground Documentation]