SSLClient  v1.4.4
Add TLS 1.2 functionality to any network library.
time_macros.h File Reference

Go to the source code of this file.

Macros

#define PST_OFFSET   (8UL)
 
#define SEC_PER_MIN   (60UL)
 
#define SEC_PER_HOUR   (3600UL)
 
#define SEC_PER_DAY   (86400UL)
 
#define SEC_PER_YEAR   (SEC_PER_DAY*365)
 
#define CONV_STR2DEC_1(str, i)   (str[i]>'0'?str[i]-'0':0)
 
#define CONV_STR2DEC_2(str, i)   (CONV_STR2DEC_1(str, i)*10 + str[i+1]-'0')
 
#define CONV_STR2DEC_3(str, i)   (CONV_STR2DEC_2(str, i)*10 + str[i+2]-'0')
 
#define CONV_STR2DEC_4(str, i)   (CONV_STR2DEC_3(str, i)*10 + str[i+3]-'0')
 
#define GET_MONTH(str, i)
 
#define __TIME_SECONDS__   CONV_STR2DEC_2(__TIME__, 6)
 
#define __TIME_MINUTES__   CONV_STR2DEC_2(__TIME__, 3)
 
#define __TIME_HOURS__   CONV_STR2DEC_2(__TIME__, 0)
 
#define __TIME_DAYS__   CONV_STR2DEC_2(__DATE__, 4)
 
#define __TIME_MONTH__   GET_MONTH(__DATE__, 0)
 
#define __TIME_YEARS__   CONV_STR2DEC_4(__DATE__, 7)
 
#define _UNIX_TIMESTAMP_FDAY(year)
 
#define _UNIX_TIMESTAMP_YDAY(year, month, day)
 
#define _UNIX_TIMESTAMP(year, month, day, hour, minute, second)
 
#define UNIX_TIMESTAMP   _UNIX_TIMESTAMP(__TIME_YEARS__, __TIME_MONTH__, __TIME_DAYS__, __TIME_HOURS__, __TIME_MINUTES__, __TIME_SECONDS__)
 
#define UNIX_TIMESTAMP_UTC   (UNIX_TIMESTAMP + (PST_OFFSET*SEC_PER_HOUR))
 

Macro Definition Documentation

◆ __TIME_DAYS__

#define __TIME_DAYS__   CONV_STR2DEC_2(__DATE__, 4)

◆ __TIME_HOURS__

#define __TIME_HOURS__   CONV_STR2DEC_2(__TIME__, 0)

◆ __TIME_MINUTES__

#define __TIME_MINUTES__   CONV_STR2DEC_2(__TIME__, 3)

◆ __TIME_MONTH__

#define __TIME_MONTH__   GET_MONTH(__DATE__, 0)

◆ __TIME_SECONDS__

#define __TIME_SECONDS__   CONV_STR2DEC_2(__TIME__, 6)

◆ __TIME_YEARS__

#define __TIME_YEARS__   CONV_STR2DEC_4(__DATE__, 7)

◆ _UNIX_TIMESTAMP

#define _UNIX_TIMESTAMP (   year,
  month,
  day,
  hour,
  minute,
  second 
)
Value:
( /* time */ second \
+ minute * SEC_PER_MIN \
+ hour * SEC_PER_HOUR \
+ /* year day (month + day) */ (_UNIX_TIMESTAMP_YDAY(year, month, day) - 1) * SEC_PER_DAY \
+ /* year */ (year - 1970UL) * SEC_PER_YEAR \
+ ((year - 1969UL) / 4UL) * SEC_PER_DAY \
- ((year - 1901UL) / 100UL) * SEC_PER_DAY \
+ ((year - 1601UL) / 400UL) * SEC_PER_DAY \
)
#define SEC_PER_MIN
Definition: time_macros.h:28
#define _UNIX_TIMESTAMP_YDAY(year, month, day)
Definition: time_macros.h:69
#define SEC_PER_HOUR
Definition: time_macros.h:29
#define SEC_PER_DAY
Definition: time_macros.h:30
#define SEC_PER_YEAR
Definition: time_macros.h:31

◆ _UNIX_TIMESTAMP_FDAY

#define _UNIX_TIMESTAMP_FDAY (   year)
Value:
(((year) % 400) == 0UL ? 29UL : \
(((year) % 100) == 0UL ? 28UL : \
(((year) % 4) == 0UL ? 29UL : \
28UL)))

◆ _UNIX_TIMESTAMP_YDAY

#define _UNIX_TIMESTAMP_YDAY (   year,
  month,
  day 
)
Value:
( \
/* January */ day \
/* February */ + (month >= 2 ? 31UL : 0UL) \
/* March */ + (month >= 3 ? _UNIX_TIMESTAMP_FDAY(year) : 0UL) \
/* April */ + (month >= 4 ? 31UL : 0UL) \
/* May */ + (month >= 5 ? 30UL : 0UL) \
/* June */ + (month >= 6 ? 31UL : 0UL) \
/* July */ + (month >= 7 ? 30UL : 0UL) \
/* August */ + (month >= 8 ? 31UL : 0UL) \
/* September */+ (month >= 9 ? 31UL : 0UL) \
/* October */ + (month >= 10 ? 30UL : 0UL) \
/* November */ + (month >= 11 ? 31UL : 0UL) \
/* December */ + (month >= 12 ? 30UL : 0UL) \
)
#define _UNIX_TIMESTAMP_FDAY(year)
Definition: time_macros.h:62

◆ CONV_STR2DEC_1

#define CONV_STR2DEC_1 (   str,
 
)    (str[i]>'0'?str[i]-'0':0)

◆ CONV_STR2DEC_2

#define CONV_STR2DEC_2 (   str,
 
)    (CONV_STR2DEC_1(str, i)*10 + str[i+1]-'0')

◆ CONV_STR2DEC_3

#define CONV_STR2DEC_3 (   str,
 
)    (CONV_STR2DEC_2(str, i)*10 + str[i+2]-'0')

◆ CONV_STR2DEC_4

#define CONV_STR2DEC_4 (   str,
 
)    (CONV_STR2DEC_3(str, i)*10 + str[i+3]-'0')

◆ GET_MONTH

#define GET_MONTH (   str,
 
)
Value:
(str[i]=='J' && str[i+1]=='a' && str[i+2]=='n' ? 1 : \
str[i]=='F' && str[i+1]=='e' && str[i+2]=='b' ? 2 : \
str[i]=='M' && str[i+1]=='a' && str[i+2]=='r' ? 3 : \
str[i]=='A' && str[i+1]=='p' && str[i+2]=='r' ? 4 : \
str[i]=='M' && str[i+1]=='a' && str[i+2]=='y' ? 5 : \
str[i]=='J' && str[i+1]=='u' && str[i+2]=='n' ? 6 : \
str[i]=='J' && str[i+1]=='u' && str[i+2]=='l' ? 7 : \
str[i]=='A' && str[i+1]=='u' && str[i+2]=='g' ? 8 : \
str[i]=='S' && str[i+1]=='e' && str[i+2]=='p' ? 9 : \
str[i]=='O' && str[i+1]=='c' && str[i+2]=='t' ? 10 : \
str[i]=='N' && str[i+1]=='o' && str[i+2]=='v' ? 11 : \
str[i]=='D' && str[i+1]=='e' && str[i+2]=='c' ? 12 : 0)

◆ PST_OFFSET

#define PST_OFFSET   (8UL)

◆ SEC_PER_DAY

#define SEC_PER_DAY   (86400UL)

◆ SEC_PER_HOUR

#define SEC_PER_HOUR   (3600UL)

◆ SEC_PER_MIN

#define SEC_PER_MIN   (60UL)

◆ SEC_PER_YEAR

#define SEC_PER_YEAR   (SEC_PER_DAY*365)

◆ UNIX_TIMESTAMP

◆ UNIX_TIMESTAMP_UTC

#define UNIX_TIMESTAMP_UTC   (UNIX_TIMESTAMP + (PST_OFFSET*SEC_PER_HOUR))