NeoMutt  2020-06-26-250-g349c94
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 struct Buffer;
32 /* theoretically time_t can be float but it is integer on most (if not all) systems */
33 #define TIME_T_MAX ((((time_t) 1 << (sizeof(time_t) * 8 - 2)) - 1) * 2 + 1)
34 #define TIME_T_MIN (-TIME_T_MAX - 1)
35 #define TM_YEAR_MAX \
36  (1970 + (((((TIME_T_MAX - 59) / 60) - 59) / 60) - 23) / 24 / 366)
37 #define TM_YEAR_MIN (1970 - (TM_YEAR_MAX - 1970) - 1)
39 #define MUTT_DATE_NOW -9999
44 struct Tz
45 {
46  char tzname[8];
47  unsigned char zhours;
48  unsigned char zminutes;
49  bool zoccident;
50 };
52 time_t mutt_date_add_timeout(time_t now, time_t timeout);
53 int mutt_date_check_month(const char *s);
54 time_t mutt_date_epoch(void);
55 uint64_t mutt_date_epoch_ms(void);
56 struct tm mutt_date_gmtime(time_t t);
57 size_t mutt_date_localtime_format(char *buf, size_t buflen, const char *format, time_t t);
58 struct tm mutt_date_localtime(time_t t);
59 time_t mutt_date_local_tz(time_t t);
60 void mutt_date_make_date(struct Buffer *buf);
61 int mutt_date_make_imap(char *buf, size_t buflen, time_t timestamp);
62 time_t mutt_date_make_time(struct tm *t, bool local);
63 int mutt_date_make_tls(char *buf, size_t buflen, time_t timestamp);
64 void mutt_date_normalize_time(struct tm *tm);
65 time_t mutt_date_parse_date(const char *s, struct Tz *tz_out);
66 time_t mutt_date_parse_imap(const char *s);
67 void mutt_date_sleep_ms(size_t ms);
69 #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:680
struct tm mutt_date_gmtime(time_t t)
Converts calendar time to a broken-down time structure expressed in UTC timezone. ...
Definition: date.c:661
struct tm mutt_date_localtime(time_t t)
Converts calendar time to a broken-down time structure expressed in user timezone.
Definition: date.c:643
String manipulation buffer.
Definition: buffer.h:33
time_t mutt_date_make_time(struct tm *t, bool local)
Convert struct tm to time_t
Definition: date.c:229
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:693
int mutt_date_make_tls(char *buf, size_t buflen, time_t timestamp)
Format date in TLS certificate verification style.
Definition: date.c:572
unsigned char zhours
Hours away from UTC.
Definition: date.h:47
char tzname[8]
Name, e.g. UTC.
Definition: date.h:46
time_t mutt_date_epoch(void)
Return the number of seconds since the Unix epoch.
Definition: date.c:416
void mutt_date_normalize_time(struct tm *tm)
Fix the contents of a struct tm.
Definition: date.c:295
time_t mutt_date_parse_date(const char *s, struct Tz *tz_out)
Parse a date string in RFC822 format.
Definition: date.c:445
bool zoccident
True if west of UTC, False if East.
Definition: date.h:49
int mutt_date_check_month(const char *s)
Is the string a valid month name.
Definition: date.c:403
unsigned char zminutes
Minutes away from UTC.
Definition: date.h:48
List of recognised Timezones.
Definition: date.h:44
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:546
time_t mutt_date_add_timeout(time_t now, time_t timeout)
Safely add a timeout to a given time_t value.
Definition: date.c:625
time_t mutt_date_parse_imap(const char *s)
Parse date of the form: DD-MMM-YYYY HH:MM:SS +ZZzz.
Definition: date.c:589
uint64_t mutt_date_epoch_ms(void)
Return the number of milliseconds since the Unix epoch.
Definition: date.c:425
void mutt_date_make_date(struct Buffer *buf)
Write a date in RFC822 format to a buffer.
Definition: date.c:377
time_t mutt_date_local_tz(time_t t)
Calculate the local timezone in seconds east of UTC.
Definition: date.c:206