A time interface class. This class replicates the normal time functions, but goes a couple of steps further. mbed library 82 and prior has a defective gmtime function. Also, this class enables access to setting the time, and adjusting the accuracy of the RTC.
Dependents: CI-data-logger-server WattEye X10Svr SSDP_Server
Diff: TimeInterface.h
- Revision:
- 10:5734dbc2f5cc
- Parent:
- 8:18489e877b0b
- Child:
- 11:1d880a50da8a
--- a/TimeInterface.h Sat Mar 26 20:36:02 2016 +0000 +++ b/TimeInterface.h Sun Jan 22 04:06:16 2017 +0000 @@ -178,6 +178,77 @@ /// size_t strftime(char * ptr, size_t maxsize, const char * format, const struct tm_ex * timeptr); + + /// Convert a string, in a defined format, to a time value in a tm_ex structure. + /// + /// Most format details leveraged from The Open Group Base Specifications Issue 6 + /// IEEE Std 1003.1, 2004 Edition + /// Copyright © 2001-2004 The IEEE and The Open Group, All Rights reserved. + /// + /// Modifications for mbed, and addition of the timezone format option by D. Smart + /// + /// @code + /// char timesample[] = "Jan 22 2017 01:32:48 UTC"; + /// tm_ex tm; + /// strptime(timesample, "%b %d %Y %H:%M:%S %Z", &tm); + /// @endcode + /// + /// @param[in] buf is a pointer to the string to be parsed. + /// @param[in] format is a pointer to a format string. See the format options. + /// @param[out] tm is a pointer to a tm_ex struct. + /// @returns a pointer to the character following the last one parsed, or null on failure + /// + /// format options: + /// - %%a The day of the week, using the locale's weekday names; either the abbreviated or + /// full name may be specified. + /// - %%A Equivalent to %%a. + /// - %%b The month, using the locale's month names; either the abbreviated or full name + /// may be specified. + /// - %%B Equivalent to %%b. + /// - %%c Replaced by the locale's appropriate date and time representation. + /// - %%C The century number [00,99]; leading zeros are permitted but not required. + /// - %%d The day of the month [01,31]; leading zeros are permitted but not required. + /// - %%D The date as %%m / %%d / %%y. + /// - %%e Equivalent to %%d. + /// - %%h Equivalent to %%b. + /// - %%H The hour (24-hour clock) [00,23]; leading zeros are permitted but not required. + /// - %%I The hour (12-hour clock) [01,12]; leading zeros are permitted but not required. + /// - %%j The day number of the year [001,366]; leading zeros are permitted but not required. + /// - %%m The month number [01,12]; leading zeros are permitted but not required. + /// - %%M The minute [00,59]; leading zeros are permitted but not required. + /// - %%n Any white space. + /// - %%p The locale's equivalent of a.m or p.m. + /// - %%r 12-hour clock time using the AM/PM notation if t_fmt_ampm is not an empty string + /// in the LC_TIME portion of the current locale; in the POSIX locale, this shall be + /// equivalent to %%I : %%M : %%S %%p. + /// - %%R The time as %%H : %%M. + /// - %%S The seconds [00,60]; leading zeros are permitted but not required. + /// - %%t Any white space. + /// - %%T The time as %%H : %%M : %%S. + /// - %%U The week number of the year (Sunday as the first day of the week) as a decimal + /// number [00,53]; leading zeros are permitted but not required. + /// - %%w The weekday as a decimal number [0,6], with 0 representing Sunday; leading zeros + /// are permitted but not required. + /// - %%W The week number of the year (Monday as the first day of the week) as a decimal + /// number [00,53]; leading zeros are permitted but not required. + /// - %%x The date, using the locale's date format. + /// - %%X The time, using the locale's time format. + /// - %%y The year within century. When a century is not otherwise specified, values in + /// the range [69,99] shall refer to years 1969 to 1999 inclusive, and values in the + /// range [00,68] shall refer to years 2000 to 2068 inclusive; leading zeros shall be + /// permitted but shall not be required. + /// Note: It is expected that in a future version of IEEE Std 1003.1-2001 + /// the default century inferred from a 2-digit year will change. + /// (This would apply to all commands accepting a 2-digit year as input.) + /// - %%Y The year, including the century (for example, 1988). + /// - %%Z The timezone offset, as a 3-letter sequence. Only a few whole-hour offsets + /// have been defined. + /// - %%%% Replaced by %%. + /// + const char * strptime(const char *buf, char *fmt, struct tm_ex *tm); + + + // time zone functions /// Set the internal RTC (clock) to the time value.