Time and timing


native! wait  Red-by-example    MyCode4fun

Stops the execution for the number of seconds given as argument.

  • Note: as of November 2017, the GUI Console does not work well with wait.


native! now  Red-by-example    MyCode4fun

Returns date and time:

>> now
== 12-Dec-2017/19:24:41-02:00

Refinements

/time - Returns time only. time!

>> now/time
== 21:42:41

/precise - High precision time. date!

>> now/precise
== 2-Apr-2018/21:49:04.647-03:00

>> a: now/time/precise
== 22:05:46.805                ;a is a time!

>> a/hour
== 22                        ;hour is an integer!

>> a/minute
== 5                        ;minute is an integer!

>> a/second
== 46.805                        ;second is a float!

This script creates a delay of 300 miliseconds (0.3 seconds):

Red []

thismoment: now/time/precise

print thismoment

while [now/time/precise < (thismoment + 00:00:00.300)][]

print now/time/precise



21:51:58.173
21:51:58.473


/year - Returns year only. integer!

>> now/year
== 2018

/month - Returns month only. integer!

>> now/month
== 4

/day - Returns day of the month only. integer!

>> now/day
== 2

/zone - Returns time zone offset from UCT (GMT) only. time!

>> now/zone
== -3:00:00

/date - Returns date only. date!

>> now/date
== 2-Apr-2018

/weekday - Returns day of the week as integer! (Monday is day 1).

>> now/weekday
== 1

/yearday - Returns day of the year (Julian). integer!

>> now/yearday
== 92

/utc - Universal time (no zone). date!


>> now/utc
== 3-Apr-2018/0:53:50


VID DLS rate  Red-by-example    MyCode4fun

Timing may also be achieved with VID dialect (GUI) using the rate facet.


< Previous topic                                                                                          Next topic >