Max 5 API Reference
00001 00002 #ifndef _SYSTIME_H_ 00003 #define _SYSTIME_H_ 00004 00005 #ifdef __cplusplus 00006 extern "C" { 00007 #endif 00008 00009 #if C74_PRAGMA_STRUCT_PACKPUSH 00010 #pragma pack(push, 2) 00011 #elif C74_PRAGMA_STRUCT_PACK 00012 #pragma pack(2) 00013 #endif 00014 00015 00016 /** 00017 The Systime data structure. 00018 @ingroup systime 00019 */ 00020 typedef struct _datetime { 00021 unsigned long year; ///< year 00022 unsigned long month; ///< month 00023 unsigned long day; ///< day 00024 unsigned long hour; ///< hour 00025 unsigned long minute; ///< minute 00026 unsigned long second; ///< second 00027 unsigned long millisecond; ///< (reserved for future use) 00028 } t_datetime; 00029 00030 00031 /** Flags for the sysdateformat_formatdatetime() function. 00032 @ingroup systime 00033 */ 00034 typedef enum { 00035 SYSDATEFORMAT_FLAGS_SHORT = 1, ///< short 00036 SYSDATEFORMAT_FLAGS_MEDIUM = 2, ///< medium 00037 SYSDATEFORMAT_FLAGS_LONG = 3 ///< long 00038 } e_max_dateflags; 00039 00040 00041 /** 00042 Find out the operating system’s time in ticks. 00043 @ingroup systime 00044 @return the system time in ticks. 00045 */ 00046 extern unsigned long systime_ticks(void); 00047 00048 00049 /** 00050 Find out the operating system’s time in milliseconds. 00051 @ingroup systime 00052 @return the system time in milliseconds. 00053 */ 00054 extern unsigned long systime_ms(void); 00055 00056 00057 /** 00058 Find out the operating system’s date and time. 00059 @ingroup systime 00060 @param d Returns the system’s date and time in a #t_datetime data structure. 00061 */ 00062 extern void systime_datetime(t_datetime *d); 00063 00064 00065 /** 00066 Find out the operating system’s time in seconds. 00067 @ingroup systime 00068 @return the system time in seconds. 00069 */ 00070 extern unsigned long systime_seconds(void); 00071 00072 00073 /** 00074 Convert a time in seconds into a #t_datetime representation. 00075 @ingroup systime 00076 @param secs A number of seconds to be represented as a #t_datetime. 00077 @param d The address of a #t_datetime that will be filled with the converted value. 00078 */ 00079 extern void systime_secondstodate(unsigned long secs, t_datetime *d); 00080 00081 00082 /** 00083 Convert a #t_datetime representation of time into seconds. 00084 @ingroup systime 00085 @param d The address of a #t_datetime that contains a valid period of time. 00086 @return The number of seconds represented by d. 00087 */ 00088 extern unsigned long systime_datetoseconds(t_datetime *d); 00089 00090 00091 00092 /** 00093 Fill a #t_datetime struct with a datetime formatted string. 00094 For example, the string "2007-12-24 12:21:00". 00095 @ingroup systime 00096 @param strf A string containing the datetime. 00097 @param d The address of a #t_datetime to fill. 00098 */ 00099 void sysdateformat_strftimetodatetime(char *strf, t_datetime *d); 00100 00101 00102 /** 00103 Get a human friendly string representation of a #t_datetime. 00104 For example: "Today", "Yesterday", etc. 00105 @ingroup systime 00106 @param d The address of a #t_datetime to fill. 00107 @param dateflags One of the values defined in #e_max_dateflags. 00108 @param timeflags Currently unused. Pass 0. 00109 @param s An already allocated string to hold the human friendly result. 00110 @param buflen The number of characters allocated to the string s. 00111 */ 00112 void sysdateformat_formatdatetime(t_datetime *d, long dateflags, long timeflags, char *s, long buflen); 00113 00114 00115 #define SYSDATEFORMAT_RELATIVE 16 00116 00117 #if C74_PRAGMA_STRUCT_PACKPUSH 00118 #pragma pack(pop) 00119 #elif C74_PRAGMA_STRUCT_PACK 00120 #pragma pack() 00121 #endif 00122 00123 #ifdef __cplusplus 00124 } 00125 #endif 00126 00127 #endif // _SYSTIME_H_ 00128
Copyright © 2008, Cycling '74