avr-libc
2.0.0
Standard C library for AVR-GCC
|
AVR Libc Home Page |
![]() |
AVR Libc Development Pages |
|||
Main Page |
User Manual |
Library Reference |
FAQ |
Example Projects |
Go to the source code of this file.
Data Structures | |
struct | tm |
struct | week_date |
Macros | |
#define | ONE_HOUR 3600 |
#define | ONE_DEGREE 3600 |
#define | ONE_DAY 86400 |
#define | UNIX_OFFSET 946684800 |
#define | NTP_OFFSET 3155673600 |
Typedefs | |
typedef uint32_t | time_t |
Enumerations | |
enum | _WEEK_DAYS_ { SUNDAY , MONDAY , TUESDAY , WEDNESDAY , THURSDAY , FRIDAY , SATURDAY } |
enum | _MONTHS_ { JANUARY , FEBRUARY , MARCH , APRIL , MAY , JUNE , JULY , AUGUST , SEPTEMBER , OCTOBER , NOVEMBER , DECEMBER } |
Functions | |
time_t | time (time_t *timer) |
int32_t | difftime (time_t time1, time_t time0) |
time_t | mktime (struct tm *timeptr) |
time_t | mk_gmtime (const struct tm *timeptr) |
struct tm * | gmtime (const time_t *timer) |
void | gmtime_r (const time_t *timer, struct tm *timeptr) |
struct tm * | localtime (const time_t *timer) |
void | localtime_r (const time_t *timer, struct tm *timeptr) |
char * | asctime (const struct tm *timeptr) |
void | asctime_r (const struct tm *timeptr, char *buf) |
char * | ctime (const time_t *timer) |
void | ctime_r (const time_t *timer, char *buf) |
char * | isotime (const struct tm *tmptr) |
void | isotime_r (const struct tm *, char *) |
size_t | strftime (char *s, size_t maxsize, const char *format, const struct tm *timeptr) |
void | set_dst (int(*)(const time_t *, int32_t *)) |
void | set_zone (int32_t) |
void | set_system_time (time_t timestamp) |
void | system_tick (void) |
uint8_t | is_leap_year (int16_t year) |
uint8_t | month_length (int16_t year, uint8_t month) |
uint8_t | week_of_year (const struct tm *timeptr, uint8_t start) |
uint8_t | week_of_month (const struct tm *timeptr, uint8_t start) |
struct week_date * | iso_week_date (int year, int yday) |
void | iso_week_date_r (int year, int yday, struct week_date *) |
uint32_t | fatfs_time (const struct tm *timeptr) |
void | set_position (int32_t latitude, int32_t longitude) |
int16_t | equation_of_time (const time_t *timer) |
int32_t | daylight_seconds (const time_t *timer) |
time_t | solar_noon (const time_t *timer) |
time_t | sun_rise (const time_t *timer) |
time_t | sun_set (const time_t *timer) |
double | solar_declination (const time_t *timer) |
int8_t | moon_phase (const time_t *timer) |
unsigned long | gm_sidereal (const time_t *timer) |
unsigned long | lm_sidereal (const time_t *timer) |
#define NTP_OFFSET 3155673600 |
Difference between the Y2K and the NTP epochs, in seconds. To convert a Y2K timestamp to NTP...
#define ONE_DAY 86400 |
One day, expressed in seconds
#define ONE_DEGREE 3600 |
Angular degree, expressed in arc seconds
#define ONE_HOUR 3600 |
One hour, expressed in seconds
#define UNIX_OFFSET 946684800 |
Difference between the Y2K and the UNIX epochs, in seconds. To convert a Y2K timestamp to UNIX...
enum _MONTHS_ |
Enumerated labels for the months.
enum _WEEK_DAYS_ |
Enumerated labels for the days of the week.
char * asctime | ( | const struct tm * | timeptr | ) |
The asctime function converts the broken-down time of timeptr, into an ascii string in the form
Sun Mar 23 01:03:52 2013
char * ctime | ( | const time_t * | timer | ) |
The ctime function is equivalent to asctime(localtime(timer))
Computes the amount of time the sun is above the horizon, at the location of the observer.
NOTE: At observer locations inside a polar circle, this value can be zero during the winter, and can exceed ONE_DAY during the summer.
The returned value is in seconds.
The difftime function returns the difference between two binary time stamps, time1 - time0.
Computes the difference between apparent solar time and mean solar time. The returned value is in seconds.
Convert a Y2K time stamp into a FAT file system time stamp.
unsigned long gm_sidereal | ( | const time_t * | timer | ) |
Returns Greenwich Mean Sidereal Time, as seconds into the sidereal day. The returned value will range from 0 through 86399 seconds.
The gmtime function converts the time stamp pointed to by timer into broken-down time, expressed as UTC.
struct week_date * iso_week_date | ( | int | year, |
int | yday | ||
) |
Return a week_date structure with the ISO_8601 week based date corresponding to the given year and day of year. See http://en.wikipedia.org/wiki/ISO_week_date for more information.
void iso_week_date_r | ( | int | year, |
int | yday, | ||
struct week_date * | iso | ||
) |
Re-entrant version of iso-week_date.
char * isotime | ( | const struct tm * | tmptr | ) |
The isotime function constructs an ascii string in the form
unsigned long lm_sidereal | ( | const time_t * | timer | ) |
Returns Local Mean Sidereal Time, as seconds into the sidereal day. The returned value will range from 0 through 86399 seconds.
The localtime function converts the time stamp pointed to by timer into broken-down time, expressed as Local time.
Re entrant version of localtime().
This function 'compiles' the elements of a broken-down time structure, returning a binary time stamp. The elements of timeptr are interpreted as representing UTC.
The original values of the tm_wday and tm_yday elements of the structure are ignored, and the original values of the other elements are not restricted to the ranges stated for struct tm.
Unlike mktime(), this function DOES NOT modify the elements of timeptr.
This function 'compiles' the elements of a broken-down time structure, returning a binary time stamp. The elements of timeptr are interpreted as representing Local Time.
The original values of the tm_wday and tm_yday elements of the structure are ignored, and the original values of the other elements are not restricted to the ranges stated for struct tm.
On successful completion, the values of all elements of timeptr are set to the appropriate range.
Return the length of month, given the year and month, where month is in the range 1 to 12.
Returns an approximation to the phase of the moon. The sign of the returned value indicates a waning or waxing phase. The magnitude of the returned value indicates the percentage illumination.
Specify the Daylight Saving function.
The Daylight Saving function should examine its parameters to determine whether Daylight Saving is in effect, and return a value appropriate for tm_isdst.
Working examples for the USA and the EU are available..
for the European Union, and
for the United States
If a Daylight Saving function is not specified, the system will ignore Daylight Saving.
Set the geographic coordinates of the 'observer', for use with several of the following functions. Parameters are passed as seconds of North Latitude, and seconds of East Longitude.
For New York City...
void set_system_time | ( | time_t | timestamp | ) |
Initialize the system time. Examples are...
From a Clock / Calendar type RTC:
From a Network Time Protocol time stamp:
From a UNIX time stamp:
void set_zone | ( | int32_t | ) |
double solar_declination | ( | const time_t * | timer | ) |
Returns the declination of the sun in radians.
Computes the time of solar noon, at the location of the observer.
size_t strftime | ( | char * | s, |
size_t | maxsize, | ||
const char * | format, | ||
const struct tm * | timeptr | ||
) |
A complete description of strftime() is beyond the pale of this document. Refer to ISO/IEC document 9899 for details.
All conversions are made using the 'C Locale', ignoring the E or O modifiers. Due to the lack of a time zone 'name', the 'Z' conversion is also ignored.
Return the time of sunrise, at the location of the observer. See the note about daylight_seconds().
Return the time of sunset, at the location of the observer. See the note about daylight_seconds().
void system_tick | ( | void | ) |
Maintain the system time by calling this function at a rate of 1 Hertz.
It is anticipated that this function will typically be called from within an Interrupt Service Routine, (though that is not required). It therefore includes code which makes it simple to use from within a 'Naked' ISR, avoiding the cost of saving and restoring all the cpu registers.
Such an ISR may resemble the following example...
The time function returns the systems current time stamp. If timer is not a null pointer, the return value is also assigned to the object it points to.
Return the calendar week of month, where the first week is considered to begin on the day of week specified by 'start'. The returned value may range from zero to 5.