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...
Go to the source code of this file.
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. 
  | 
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);.  
  | 
| 
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.  
  | 
| 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.  
  | 
| 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.  
  | 
| 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.  
  | 
| datetime  | dt_fromEt (int et) | 
|   | Get the datetime representation of an a Unix epoch time (number of seconds from Midnight, 1/1/1970).  
  | 
| 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.  
  | 
| 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.  
  | 
| 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.  
  | 
| 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.  
  | 
Detailed Description
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.6
 
- Copyright
 - Copyright (c) Parallax Inc 2015. All rights MIT licensed; see end of file. 
 
Definition in file datetime.h.
Typedef Documentation
< datetime_st Structure containing y, mo, h, m, s, and etv elements. 
datetime Type definition of datetime_st structure. 
 
 
Function Documentation
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. 
- Parameters
 - 
  
    | 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. | 
  
   
- Returns
 - A copy of the datetime type with updated date fields. 
 
 
 
Get the datetime representation of an a Unix epoch time (number of seconds from Midnight, 1/1/1970). 
- Parameters
 - 
  
    | et | The number of seconds that date is from Midnight, 1/1/1970. | 
  
   
- Returns
 - dt A datetime type with the equivalent date and time. 
 
 
 
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. 
- Parameters
 - 
  
    | 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. | 
  
   
- Returns
 - A copy of the datetime type with updated time fields. 
 
 
 
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. 
- Returns
 - The datetime representation of the current system time. 
 
 
 
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. 
- Returns
 - Milliseconds since into the current second. This second . 
 
 
 
Run a date/time second counting process in another cog. Example: datetime dts = {2015, 9, 25, 8, 11, 04}; dt_run(dts);. 
- Parameters
 - 
  
    | dt | A datetime structure, pre-set before the call.  | 
  
   
 
 
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. 
- Parameters
 - 
  
    | dt | A datetime type containing the new date and time.  | 
  
   
 
 
      
        
          | 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. 
- Parameters
 - 
  
    | dt | Datetime type containing a valid date. | 
    | *s | String (minimum 9 characters) address.  | 
  
   
 
 
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. 
- Parameters
 - 
  
    | dt | A datetime type that contains a valid date and time. | 
  
   
- Returns
 - et The number of seconds that date is from Midnight, 1/1/1970. 
 
 
 
      
        
          | 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. 
- Parameters
 - 
  
    | dt | Datetime type containing a valid time. | 
    | *s | String (minimum 9 characters) address.  |