This library provides convenient functions for a variety of timekeeping operations. Incorporates a manual Spin to C translation of Bob Belleville's date_time_ts.spin for timekeeping.
More...
Functions |
int | dt_start (datetime *dts) |
| Start a date/time second counting process in another cog. Example: datetime dts = {2015, 9, 25, 8, 11, 04}; int cogid = dt_start(&dts);.
|
void | dt_stop () |
| Stop a date/time second counting process and recover the cog and lock.
|
int | dt_set (datetime *dt, int y, int mo, int d, int h, int m, int s) |
| set a datetime type. Example datetime mydt; dt_set(&mydt, 2015, 9, 25, 8, 13, 51); You can also use this to change the the datetime type that was used in dt_start to "set" the second counter that auto-increments.
|
void | dt_copy (datetime *dtDest, datetime *dtSrc) |
| Copy contents of one time type to another. Example: datetime a = {2015, 9, 25, 8, 24, 45}; datetime b = {2015, 9, 25, 8, 24, 35}; dt_copy(&a, &b); Regardless of what it stored previously, the a time will contain the b time's contents after the call.
|
int | dt_cmpSec (datetime *dtTarget, datetime *dtCmpVal) |
| Compare etv second values of two datetime types. Example: datetime a = {2015, 9, 25, 8, 24, 45}; datetime b = {2015, 9, 25, 8, 24, 35}; dt_cmpSec(&a, &b); The result will be 10. Swap arguments, and the result will be -10. Useful for setting alarms and comparing with system time.
|
void | dt_addSec (datetime *dt, int seconds) |
| Add a number of seconds to a given datetime type. Example: datetime a = {2001, 1, 1, 0, 0, 0}; dt_addSec(&a, DAYS*1+HOURS*3 +MINUTES*4+SECONDS*5); Result: a == {2001, 1, 2, 3, 4, 5}.
|
This library provides convenient functions for a variety of timekeeping operations. Incorporates a manual Spin to C translation of Bob Belleville's date_time_ts.spin for timekeeping.
- Author
- Parallax Inc.
- Version
- 0.5
- Copyright
- Copyright (c) Parallax Inc 2015. All rights MIT licensed; see end of file.
Definition in file datetime.h.
void dt_addSec |
( |
datetime * |
dt, |
|
|
int |
seconds |
|
) |
| |
Add a number of seconds to a given datetime type. Example: datetime a = {2001, 1, 1, 0, 0, 0}; dt_addSec(&a, DAYS*1+HOURS*3 +MINUTES*4+SECONDS*5); Result: a == {2001, 1, 2, 3, 4, 5}.
- Parameters
-
*dt | The daytime type to be modified. |
seconds | The number of seconds to add. May be multiplied by convenient values like DAYS, HOURS, MINUTES, or SECONDS. |
Compare etv second values of two datetime types. Example: datetime a = {2015, 9, 25, 8, 24, 45}; datetime b = {2015, 9, 25, 8, 24, 35}; dt_cmpSec(&a, &b); The result will be 10. Swap arguments, and the result will be -10. Useful for setting alarms and comparing with system time.
- Parameters
-
*dtTarget | Address of target time. The number of seconds corresponding from this date/time that the dtCmpVal second value is subracted from. |
*dtCmpVal | The number seconds corresponding to this date/time are subtracted from the target value. |
- Returns
- The number of seconds difference: dtTarget - dtCmpVal.
Copy contents of one time type to another. Example: datetime a = {2015, 9, 25, 8, 24, 45}; datetime b = {2015, 9, 25, 8, 24, 35}; dt_copy(&a, &b); Regardless of what it stored previously, the a time will contain the b time's contents after the call.
- Parameters
-
*dtDest | Address of destination time receives dtSrc values. |
*dtSrc | Address of source time copied to dtDest. |