Max API  8.2.0
Systime API

The Systime API provides the means of getting the system time, instead of the scheduler time as you would with functions like gettime(). More...

+ Collaboration diagram for Systime API:

Data Structures

struct  t_datetime
 The Systime data structure. More...
 

Enumerations

enum  e_max_dateflags { SYSDATEFORMAT_FLAGS_SHORT , SYSDATEFORMAT_FLAGS_MEDIUM , SYSDATEFORMAT_FLAGS_LONG , SYSDATEFORMAT_RELATIVE }
 Flags for the sysdateformat_formatdatetime() function. More...
 

Functions

t_uint32 systime_ticks (void)
 Find out the operating system’s time in ticks. More...
 
t_uint32 systime_ms (void)
 Find out the operating system’s time in milliseconds. More...
 
t_int64 systime_datetime_milliseconds (void)
 Find out the current date/time as number of ms since January 1, 1970, GMT. More...
 
void systime_datetime (t_datetime *d)
 Find out the operating system’s current local date and time. More...
 
t_ptr_uint systime_seconds (void)
 Find out the operating system’s time in seconds since midnight, January 1, 1904, GMT (mac HFS time). More...
 
void systime_secondstodate (t_ptr_uint secs, t_datetime *d)
 Convert a time in seconds into a t_datetime representation. More...
 
t_ptr_uint systime_datetoseconds (const t_datetime *d)
 Convert a t_datetime representation of time into seconds since midnight, January 1, 1904, GMT. More...
 
void sysdateformat_strftimetodatetime (const char *strf, t_datetime *d)
 Fill a t_datetime struct with a datetime formatted string. More...
 
void sysdateformat_formatdatetime (const t_datetime *d, long dateflags, long timeflags, char *s, long buflen)
 Get a human friendly string representation of a t_datetime. More...
 

Detailed Description

The Systime API provides the means of getting the system time, instead of the scheduler time as you would with functions like gettime().

Enumeration Type Documentation

◆ e_max_dateflags

Flags for the sysdateformat_formatdatetime() function.

Enumerator
SYSDATEFORMAT_FLAGS_SHORT 

short

SYSDATEFORMAT_FLAGS_MEDIUM 

medium

SYSDATEFORMAT_FLAGS_LONG 

long

Function Documentation

◆ sysdateformat_formatdatetime()

void sysdateformat_formatdatetime ( const t_datetime d,
long  dateflags,
long  timeflags,
char *  s,
long  buflen 
)

Get a human friendly string representation of a t_datetime.

For example: "Dec 17, 2020 at 10:48 AM" or, when dateflags is SYSDATEFORMAT_RELATIVE a string like "Today", "Yesterday", etc.

Parameters
dThe address of a t_datetime to format as a string. The t_datetime entries correspond to the local time.
dateflagsOne of the values defined in e_max_dateflags.
timeflagsCurrently unused. Pass 0.
sAn already allocated string to hold the human friendly result.
buflenThe number of characters allocated to the string s.

◆ sysdateformat_strftimetodatetime()

void sysdateformat_strftimetodatetime ( const char *  strf,
t_datetime d 
)

Fill a t_datetime struct with a datetime formatted string.

For example, the string "2007-12-24 12:21:00".

Parameters
strfA string containing the datetime.
dThe address of a t_datetime to fill.

◆ systime_datetime()

void systime_datetime ( t_datetime d)

Find out the operating system’s current local date and time.

Parameters
dReturns the system’s date and time in the local time zone in a t_datetime data structure.

◆ systime_datetime_milliseconds()

t_int64 systime_datetime_milliseconds ( void  )

Find out the current date/time as number of ms since January 1, 1970, GMT.

Returns
the number of milliseconds since January 1, 1970, GMT.

◆ systime_datetoseconds()

t_ptr_uint systime_datetoseconds ( const t_datetime d)

Convert a t_datetime representation of time into seconds since midnight, January 1, 1904, GMT.

Parameters
dThe address of a t_datetime to be converted to seconds. The t_datetime values are in the local time zone.
Returns
The number of seconds between midnight, January 1, 1904, GMT and the time represented in d.

◆ systime_ms()

t_uint32 systime_ms ( void  )

Find out the operating system’s time in milliseconds.

Note that this is approximately the number of milliseconds since the OS was started up.

Returns
the system time in milliseconds.

◆ systime_seconds()

t_ptr_uint systime_seconds ( void  )

Find out the operating system’s time in seconds since midnight, January 1, 1904, GMT (mac HFS time).

Returns
the system time in seconds since midnight, January 1, 1904, GMT.

◆ systime_secondstodate()

void systime_secondstodate ( t_ptr_uint  secs,
t_datetime d 
)

Convert a time in seconds into a t_datetime representation.

Parameters
secsA number of seconds since midnight, January 1, 1904, GMT, to be represented as a t_datetime.
dThe address of a t_datetime that will be filled to the corresponding time, in the local time zone.

◆ systime_ticks()

t_uint32 systime_ticks ( void  )

Find out the operating system’s time in ticks.

Returns
the system time in ticks.

Referenced by jit_rand_setseed().