PropWare
2.1.2
C++ objects and CMake build system for Parallax Propeller
|
Click here for docs on the
develop
branch.
This library provides convenient functions for a variety of timekeeping operations. This library makes use of a manual Spin to C translation of functions from Bob Belleville's date_time_epoch.spin for converting to/from between epoch time (seconds from midnight, 1/1/1970) and a datetime format. More...
Go to the source code of this file.
Classes | |
struct | datetime_st |
< datetime_st Structure containing y, mo, h, m, and s elements. More... | |
Macros | |
#define | SECONDS 1 |
Constant 1 for 1 second. | |
#define | MINUTES 60 |
Constant 60 for seconds in a minute. | |
#define | HOURS 60 * MINUTES |
Constant 3600 for seconds in an hour. | |
#define | DAYS 24 * HOURS |
Constant 86400 for seconds in a day. | |
#define | _eunix 2440588 |
#define | _edos 2444240 |
#define | _eprop 2451545 |
#define | _epoch _eunix |
Typedefs | |
typedef struct datetime_st | datetime |
< datetime_st Structure containing y, mo, h, m, and s elements. More... | |
Functions | |
void | dt_run (datetime dt) |
Run a date/time second counting process in another cog. Example: datetime dts = {2015, 9, 25, 8, 11, 04}; dt_run(dts);. More... | |
void | dt_end () |
Stop a date/time second counting process and recover the cog and lock. | |
void | dt_set (datetime dt) |
Set the system date and time. This can be used to change the system's current date/time. Example datetime mydt={2015, 9, 25, 8, 13, 51}; dt_set(mydt); You can also use this to change the datetime type that was used in dt_start to "set" the second counter that auto-increments. More... | |
datetime | dt_get () |
Get the current system time. To find the current system time (as a datetime type), call this function. Note: This assumes that a call to dt_run has been made. This is common near the beginning of a program that uses the system timekeeping. More... | |
int | dt_getms () |
Get the number of ms into the current second from the system time second. Notes: This assumes that a call to dt_run has been made. This is common near the beginning of a program that uses the system timekeeping. The current second can be captured with dt_get. More... | |
int | dt_toEt (datetime dt) |
Get the Unix epoch time (number of seconds from Midnight, 1/1/1970) from a datetime type. This number is a common form of timekeeping for computer systems. More... | |
datetime | dt_fromEt (int et) |
Get the datetime representation of an a Unix epoch time (number of seconds from Midnight, 1/1/1970). More... | |
void | dt_toDateStr (datetime dt, char *s) |
Populates a string (minimum 9 characters) with the mm/dd/yy representation of a datetime type's date. More... | |
void | dt_toTimeStr (datetime dt, char *s) |
Populates a string (minimum 9 characters) with the hh:mm:ss representation of a datetime type's time. More... | |
datetime | dt_fromDateStr (datetime dt, char *s) |
Populates the y, mo, and d fields in a datetime type with value representations of the characters in a string that contains the date in mm/dd/yy format. More... | |
datetime | dt_fromTimeStr (datetime dt, char *s) |
Populates the time fields (h, m, and s) in a datetime type with value representations of the characters in a string that contains the time in hh/mm/ss format. More... | |
void | secondctr (void *par) |
int | dte_toJD (int y, int m, int d) |
int | dte_toSPD (int h, int m, int s) |
int | dte_toCal (int jd) |
int | dte_dateETV (int etv) |
int | dte_timeETV (int etv) |
This library provides convenient functions for a variety of timekeeping operations. This library makes use of a manual Spin to C translation of functions from Bob Belleville's date_time_epoch.spin for converting to/from between epoch time (seconds from midnight, 1/1/1970) and a datetime format.
Definition in file datetime.h.
struct datetime_st |
< datetime_st Structure containing y, mo, h, m, and s elements.
Definition at line 56 of file datetime.h.
Class Members | ||
---|---|---|
volatile int | d | Day. |
volatile int | h | Hour. |
volatile int | m | Minute. |
volatile int | mo | Month. |
volatile int | s | Second. |
volatile int | y | Year. |
typedef struct datetime_st datetime |
< datetime_st Structure containing y, mo, h, m, and s elements.
datetime Type definition of datetime_st structure.
Populates the y, mo, and d fields in a datetime type with value representations of the characters in a string that contains the date in mm/dd/yy format.
dt | Datetime type. This datetime type may already contain a time that will be unaffected. Only the date (y, mo, d) fields will be changed. |
*s | String (minimum 9 characters) containing the date in mm/dd/yy format. |
Definition at line 11 of file dt_fromDateStr.c.
datetime dt_fromEt | ( | int | et | ) |
Get the datetime representation of an a Unix epoch time (number of seconds from Midnight, 1/1/1970).
et | The number of seconds that date is from Midnight, 1/1/1970. |
Definition at line 11 of file dt_fromEt.c.
Populates the time fields (h, m, and s) in a datetime type with value representations of the characters in a string that contains the time in hh/mm/ss format.
dt | Datetime type. This datetime type may already contain a date that will be unaffected. Only the date (h, m, s) fields will be changed. |
*s | String (minimum 9 characters) containing the time in hh:mm:ss format. |
Definition at line 11 of file dt_fromTimeStr.c.
datetime dt_get | ( | ) |
Get the current system time. To find the current system time (as a datetime type), call this function. Note: This assumes that a call to dt_run has been made. This is common near the beginning of a program that uses the system timekeeping.
Definition at line 30 of file datetime.c.
int dt_getms | ( | ) |
Get the number of ms into the current second from the system time second. Notes: This assumes that a call to dt_run has been made. This is common near the beginning of a program that uses the system timekeeping. The current second can be captured with dt_get.
Definition at line 57 of file datetime.c.
void dt_run | ( | datetime | dt | ) |
Run a date/time second counting process in another cog. Example: datetime dts = {2015, 9, 25, 8, 11, 04}; dt_run(dts);.
dt | A datetime structure, pre-set before the call. |
Definition at line 42 of file datetime.c.
void dt_set | ( | datetime | dt | ) |
Set the system date and time. This can be used to change the system's current date/time. Example datetime mydt={2015, 9, 25, 8, 13, 51}; dt_set(mydt); You can also use this to change the datetime type that was used in dt_start to "set" the second counter that auto-increments.
dt | A datetime type containing the new date and time. |
Definition at line 37 of file datetime.c.
void dt_toDateStr | ( | datetime | dt, |
char * | s | ||
) |
Populates a string (minimum 9 characters) with the mm/dd/yy representation of a datetime type's date.
dt | Datetime type containing a valid date. |
*s | String (minimum 9 characters) address. |
Definition at line 11 of file dt_toDateStr.c.
int dt_toEt | ( | datetime | dt | ) |
Get the Unix epoch time (number of seconds from Midnight, 1/1/1970) from a datetime type. This number is a common form of timekeeping for computer systems.
dt | A datetime type that contains a valid date and time. |
Definition at line 15 of file dt_toEt.c.
void dt_toTimeStr | ( | datetime | dt, |
char * | s | ||
) |
Populates a string (minimum 9 characters) with the hh:mm:ss representation of a datetime type's time.
dt | Datetime type containing a valid time. |
*s | String (minimum 9 characters) address. |
Definition at line 11 of file dt_toTimeStr.c.