Arduino-RTC
Real-Time Clock (RTC) library for Arduino
time.h File Reference
#include <stdint.h>
#include <string.h>
Include dependency graph for time.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  tm
 

Macros

#define ONE_HOUR   3600
 
#define ONE_DEGREE   3600
 
#define ONE_DAY   86400UL
 
#define UNIX_OFFSET   946684800UL
 
#define NTP_OFFSET   3155673600UL
 

Typedefs

typedef uint32_t time_t
 

Enumerations

enum  {
  SUNDAY, MONDAY, TUESDAY, WEDNESDAY,
  THURSDAY, FRIDAY, SATURDAY
}
 
enum  {
  JANUARY, FEBRUARY, MARCH, APRIL,
  MAY, JUNE, JULY, AUGUST,
  SEPTEMBER, OCTOBER, NOVEMBER, DECEMBER
}
 

Functions

int32_t difftime (time_t time1, time_t time0)
 
time_t mktime (struct tm *timeptr)
 
time_t mk_gmtime (const struct tm *timeptr)
 
struct tmgmtime_r (const time_t *timer, struct tm *timeptr)
 
struct tmlocaltime_r (const time_t *timer, struct tm *timeptr)
 
char * isotime_r (const struct tm *tmptr, char *buf)
 
uint8_t is_leap_year (int16_t year)
 
void set_dst (int(*)(const time_t *, int32_t *))
 
void set_zone (int32_t)
 
int32_t get_zone ()
 

Detailed Description

Version
1.0

License

Copyright (C) 2017, Mikael Patel

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

Definition in file time.h.

Macro Definition Documentation

#define NTP_OFFSET   3155673600UL

Difference between the Y2K and the NTP epochs, in seconds.

Definition at line 160 of file time.h.

#define ONE_DAY   86400UL

One day, expressed in seconds

Definition at line 154 of file time.h.

#define ONE_DEGREE   3600

Angular degree, expressed in arc seconds

Definition at line 151 of file time.h.

#define ONE_HOUR   3600

One hour, expressed in seconds

Definition at line 148 of file time.h.

#define UNIX_OFFSET   946684800UL

Difference between the Y2K and the UNIX epochs, in seconds.

Definition at line 157 of file time.h.

Typedef Documentation

typedef uint32_t time_t

time_t represents seconds elapsed from Midnight, Jan 1 2000 UTC (the Y2K 'epoch'). Its range allows this implementation to represent time up to Tue Feb 7 06:28:15 2136 UTC.

Definition at line 30 of file time.h.

Enumeration Type Documentation

anonymous enum
Enumerator
SUNDAY 
MONDAY 
TUESDAY 
WEDNESDAY 
THURSDAY 
FRIDAY 
SATURDAY 

Definition at line 67 of file time.h.

anonymous enum
Enumerator
JANUARY 
FEBRUARY 
MARCH 
APRIL 
MAY 
JUNE 
JULY 
AUGUST 
SEPTEMBER 
OCTOBER 
NOVEMBER 
DECEMBER 

Definition at line 77 of file time.h.

Function Documentation

int32_t difftime ( time_t  time1,
time_t  time0 
)

The difftime function returns the difference between two binary time stamps, time1 - time0.

Definition at line 32 of file difftime.cpp.

int32_t get_zone ( )

Definition at line 40 of file set_zone.cpp.

struct tm* gmtime_r ( const time_t timer,
struct tm timeptr 
)

The gmtime function converts the time stamp pointed to by timer into broken-down time, expressed as UTC.

Definition at line 33 of file gmtime_r.cpp.

uint8_t is_leap_year ( int16_t  year)

Return 1 if year is a leap year, zero if it is not.

char* isotime_r ( const struct tm tmptr,
char *  buf 
)

The isotime function constructs an ascii string in the form

1 YYYY-MM-DD hh:mm:ss

Definition at line 34 of file isotime_r.cpp.

struct tm* localtime_r ( const time_t timer,
struct tm timeptr 
)

The localtime function converts the time stamp pointed to by timer into broken-down time, expressed as Local time.

Definition at line 35 of file localtime_r.cpp.

time_t mk_gmtime ( const struct tm 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 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.

Definition at line 32 of file mk_gmtime.cpp.

time_t mktime ( struct tm 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.

Definition at line 35 of file mktime.cpp.

void set_dst ( int(*)(const time_t *, int32_t *)  )

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.

If a Daylight Saving function is not specified, the system will ignore Daylight Saving.

Definition at line 34 of file set_dst.cpp.

void set_zone ( int32_t  )

Set the 'time zone'. The parameter is given in seconds East of the Prime Meridian. Example for New York City:

1  set_zone(-5 *
2 ONE_HOUR);

If the time zone is not set, the time system will operate in UTC only.

Definition at line 34 of file set_zone.cpp.