NeoMutt  2019-12-07-168-gc45f47
Teaching an old dog new tricks
Go to the documentation of this file.
23 #ifndef MUTT_LIB_DATE_H
24 #define MUTT_LIB_DATE_H
26 #include <stdbool.h>
27 #include <stdint.h>
28 #include <time.h>
30 /* theoretically time_t can be float but it is integer on most (if not all) systems */
31 #define TIME_T_MAX ((((time_t) 1 << (sizeof(time_t) * 8 - 2)) - 1) * 2 + 1)
32 #define TIME_T_MIN (-TIME_T_MAX - 1)
33 #define TM_YEAR_MAX \
34  (1970 + (((((TIME_T_MAX - 59) / 60) - 59) / 60) - 23) / 24 / 366)
35 #define TM_YEAR_MIN (1970 - (TM_YEAR_MAX - 1970) - 1)
37 #define MUTT_DATE_NOW -9999
42 struct Tz
43 {
44  char tzname[5];
45  unsigned char zhours;
46  unsigned char zminutes;
47  bool zoccident;
48 };
50 time_t mutt_date_add_timeout(time_t now, long timeout);
51 int mutt_date_check_month(const char *s);
52 time_t mutt_date_epoch(void);
53 uint64_t mutt_date_epoch_ms(void);
54 struct tm mutt_date_gmtime(time_t t);
55 bool mutt_date_is_day_name(const char *s);
56 size_t mutt_date_localtime_format(char *buf, size_t buflen, const char *format, time_t t);
57 struct tm mutt_date_localtime(time_t t);
58 time_t mutt_date_local_tz(time_t t);
59 char * mutt_date_make_date(char *buf, size_t buflen);
60 int mutt_date_make_imap(char *buf, size_t buflen, time_t timestamp);
61 time_t mutt_date_make_time(struct tm *t, bool local);
62 int mutt_date_make_tls(char *buf, size_t buflen, time_t timestamp);
63 void mutt_date_normalize_time(struct tm *tm);
64 time_t mutt_date_parse_date(const char *s, struct Tz *tz_out);
65 time_t mutt_date_parse_imap(const char *s);
66 void mutt_date_sleep_ms(size_t ms);
68 #endif /* MUTT_LIB_DATE_H */
size_t mutt_date_localtime_format(char *buf, size_t buflen, const char *format, time_t t)
Format localtime.
Definition: date.c:774
struct tm mutt_date_gmtime(time_t t)
Converts calendar time to a broken-down time structure expressed in UTC timezone. ...
Definition: date.c:755
struct tm mutt_date_localtime(time_t t)
Converts calendar time to a broken-down time structure expressed in user timezone.
Definition: date.c:737
time_t mutt_date_make_time(struct tm *t, bool local)
Convert struct tm to time_t
Definition: date.c:225
static const char * timestamp(time_t stamp)
Create a YYYY-MM-DD HH:MM:SS timestamp.
Definition: logging.c:77
void mutt_date_sleep_ms(size_t ms)
Sleep for milliseconds.
Definition: date.c:787
int mutt_date_make_tls(char *buf, size_t buflen, time_t timestamp)
Format date in TLS certificate verification style.
Definition: date.c:644
unsigned char zhours
Hours away from UTC.
Definition: date.h:45
time_t mutt_date_epoch(void)
Return the number of seconds since the Unix epoch.
Definition: date.c:411
void mutt_date_normalize_time(struct tm *tm)
Fix the contents of a struct tm.
Definition: date.c:291
time_t mutt_date_parse_date(const char *s, struct Tz *tz_out)
Parse a date string in RFC822 format.
Definition: date.c:460
bool zoccident
True if west of UTC, False if East.
Definition: date.h:47
char tzname[5]
Name, e.g. UTC.
Definition: date.h:44
time_t mutt_date_add_timeout(time_t now, long timeout)
Safely add a timeout to a given time_t value.
Definition: date.c:719
int mutt_date_check_month(const char *s)
Is the string a valid month name.
Definition: date.c:398
unsigned char zminutes
Minutes away from UTC.
Definition: date.h:46
List of recognised Timezones.
Definition: date.h:42
bool mutt_date_is_day_name(const char *s)
Is the string a valid day name.
Definition: date.c:437
char * mutt_date_make_date(char *buf, size_t buflen)
Write a date in RFC822 format to a buffer.
Definition: date.c:372
int mutt_date_make_imap(char *buf, size_t buflen, time_t timestamp)
Format date in IMAP style: DD-MMM-YYYY HH:MM:SS +ZZzz.
Definition: date.c:618
time_t mutt_date_parse_imap(const char *s)
Parse date of the form: DD-MMM-YYYY HH:MM:SS +ZZzz.
Definition: date.c:661
uint64_t mutt_date_epoch_ms(void)
Return the number of milliseconds since the Unix epoch.
Definition: date.c:420
time_t mutt_date_local_tz(time_t t)
Calculate the local timezone in seconds east of UTC.
Definition: date.c:202