Time ライブラリ


Abstract

The VCSSL Time library is a standard library providing functions such as time measurement and current time retrieval.

The function for obtaining elapsed time is provided by the time() function. This function returns the elapsed time since the start of program execution.
(In some languages, such functions return the elapsed time since 00:00 on January 1, 1970, but that is not the case in VCSSL.)

The precision, or unit, of the time returned by the time function is milliseconds in the standard implementation.However, functions are also provided for converting the return value of the time function into various time units,for cases where you want to avoid hard-coded values such as " /1000 " when converting units,or when you want to consider portability to special implementations with different units, though none currently exist.
Specifically, the millisecond function converts to milliseconds, the second function to seconds, the minute function to minutes, the hour function to hours, and the day function to days.
For example, to perform some processing and measure the elapsed time for it, do as follows:

int t1 = time(); // Measure the start time

[ Perform some time-consuming processing here ]

int t2 = time(); // Measure the end time
int sec = second( t2 - t1 ); // Obtain the elapsed time (time difference) in seconds
print( "Elapsed time [ s ] = " + sec ); // Output

Also, if the second, minute, and hour functions are called without arguments, they return the current clock time.
Similarly, if the day, month, and year functions are called without arguments, they return the current calendar date.
For example, to display the current date and time, do as follows:

print( year() + "/" + month() + "/" + day() + " " + hour() + ":" + minute() + ":" + second() );


Index

int time()
Returns the elapsed time since the start of program execution in milliseconds.Because this function is used frequently, it has also been supported in the System library since VCSSL 3.4.22.Therefore, this function can now be used without importing the Time library.(This is because all functions belonging to the System library can be used without import.)
int millisecond( int t )
Converts a value returned by the time function and so on into milliseconds, that is, returns it as is.
int second( int t )
Converts a value returned by the time function and so on into seconds. Any remainder less than one second is discarded.
int minute( int t )
Converts a value returned by the time function and so on into minutes. Any remainder less than one minute is discarded.
int hour( int t )
Converts a value returned by the time function and so on into hours. Any remainder less than one hour is discarded.
int day( int t )
Converts a value returned by the time function and so on into days. Any remainder less than one day is discarded.Note that astronomical and physical effects such as fluctuations in the Earth's rotation speed and leap seconds are not taken into account. Conversion is performed simply by treating 86400000 milliseconds as one day.
int year()
Returns the current year in the Gregorian calendar.
int month()
Returns the current month in the Gregorian calendar.The range is 1 to 12. Note that it is not 0 to 11.
int day()
Returns the current day in the Gregorian calendar.
int hour()
Returns the current hour of the day.
int minute()
Returns the current minute of the time.
int second()
Returns the current second of the time.
string date()
Returns a text representing the current date and time in the Gregorian calendar.The format is currently unspecified in the specification and depends on the implementation. If you need a guaranteed format, construct it yourself by using functions such as year and hour.

Structs

- None -


Variables

- None -


Functions

Name time
Declaration int time()
Description Returns the elapsed time since the start of program execution in milliseconds.
Because this function is used frequently, it has also been supported in the System library since VCSSL 3.4.22.Therefore, this function can now be used without importing the Time library.
(This is because all functions belonging to the System library can be used without import.)
Return (int type) The elapsed time since the start of program execution, in milliseconds.
Name millisecond
Declaration int millisecond( int t )
Description Converts a value returned by the time function and so on into milliseconds, that is, returns it as is.
Parameters (int type) t : The time to be converted, such as a return value of the time function or a sum or difference of such values.
Return (int type) The value converted to milliseconds.
Name second
Declaration int second( int t )
Description Converts a value returned by the time function and so on into seconds. Any remainder less than one second is discarded.
Parameters (int type) t : The time to be converted, such as a return value of the time function or a sum or difference of such values.
Return (int type) The value converted to seconds.
Name minute
Declaration int minute( int t )
Description Converts a value returned by the time function and so on into minutes. Any remainder less than one minute is discarded.
Parameters (int type) t : The time to be converted, such as a return value of the time function or a sum or difference of such values.
Return (int type) The value converted to minutes.
Name hour
Declaration int hour( int t )
Description Converts a value returned by the time function and so on into hours. Any remainder less than one hour is discarded.
Parameters (int type) t : The time to be converted, such as a return value of the time function or a sum or difference of such values.
Return (int type) The value converted to hours.
Name day
Declaration int day( int t )
Description Converts a value returned by the time function and so on into days. Any remainder less than one day is discarded.Note that astronomical and physical effects such as fluctuations in the Earth's rotation speed and leap seconds are not taken into account. Conversion is performed simply by treating 86400000 milliseconds as one day.
Parameters (int type) t : The time to be converted, such as a return value of the time function or a sum or difference of such values.
Return (int type) The value converted to days.
Name year
Declaration int year()
Description Returns the current year in the Gregorian calendar.
Return (int type) The current year.
Name month
Declaration int month()
Description Returns the current month in the Gregorian calendar.
The range is 1 to 12. Note that it is not 0 to 11.
Return (int type) The current month.
Name day
Declaration int day()
Description Returns the current day in the Gregorian calendar.
Return (int type) The current day.
Name hour
Declaration int hour()
Description Returns the current hour of the day.
Return (int type) The current hour.
Name minute
Declaration int minute()
Description Returns the current minute of the time.
Return (int type) The current minute.
Name second
Declaration int second()
Description Returns the current second of the time.
Return (int type) The current second.
Name date
Declaration string date()
Description Returns a text representing the current date and time in the Gregorian calendar.
The format is currently unspecified in the specification and depends on the implementation. If you need a guaranteed format, construct it yourself by using functions such as year and hour.
Return (string type) A text representing the date and time.