NeoMutt  2022-04-29-323-g5fcc6c
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>
30struct 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
44struct Tz
46 char tzname[8];
47 unsigned char zhours;
48 unsigned char zminutes;
49 bool zoccident;
52time_t mutt_date_add_timeout(time_t now, time_t timeout);
53int mutt_date_check_month(const char *s);
54time_t mutt_date_epoch(void);
55uint64_t mutt_date_epoch_ms(void);
56struct tm mutt_date_gmtime(time_t t);
57size_t mutt_date_localtime_format(char *buf, size_t buflen, const char *format, time_t t);
58struct tm mutt_date_localtime(time_t t);
59int mutt_date_local_tz(time_t t);
60void mutt_date_make_date(struct Buffer *buf, bool local);
61int mutt_date_make_imap(char *buf, size_t buflen, time_t timestamp);
62time_t mutt_date_make_time(struct tm *t, bool local);
63int mutt_date_make_tls(char *buf, size_t buflen, time_t timestamp);
64void mutt_date_normalize_time(struct tm *tm);
65time_t mutt_date_parse_date(const char *s, struct Tz *tz_out);
66time_t mutt_date_parse_imap(const char *s);
67void mutt_date_sleep_ms(size_t ms);
69#endif /* MUTT_LIB_DATE_H */
struct tm mutt_date_localtime(time_t t)
Converts calendar time to a broken-down time structure expressed in user timezone.
Definition: date.c:655
size_t mutt_date_localtime_format(char *buf, size_t buflen, const char *format, time_t t)
Format localtime.
Definition: date.c:692
void mutt_date_make_date(struct Buffer *buf, bool local)
Write a date in RFC822 format to a buffer.
Definition: date.c:380
time_t mutt_date_make_time(struct tm *t, bool local)
Convert struct tm to time_t
Definition: date.c:229
void mutt_date_sleep_ms(size_t ms)
Sleep for milliseconds.
Definition: date.c:705
int mutt_date_check_month(const char *s)
Is the string a valid month name.
Definition: date.c:415
struct tm mutt_date_gmtime(time_t t)
Converts calendar time to a broken-down time structure expressed in UTC timezone.
Definition: date.c:673
int mutt_date_make_tls(char *buf, size_t buflen, time_t timestamp)
Format date in TLS certificate verification style.
Definition: date.c:584
time_t mutt_date_epoch(void)
Return the number of seconds since the Unix epoch.
Definition: date.c:428
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:558
int mutt_date_local_tz(time_t t)
Calculate the local timezone in seconds east of UTC.
Definition: date.c:206
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:637
time_t mutt_date_parse_date(const char *s, struct Tz *tz_out)
Parse a date string in RFC822 format.
Definition: date.c:457
time_t mutt_date_parse_imap(const char *s)
Parse date of the form: DD-MMM-YYYY HH:MM:SS +ZZzz.
Definition: date.c:601
void mutt_date_normalize_time(struct tm *tm)
Fix the contents of a struct tm.
Definition: date.c:297
uint64_t mutt_date_epoch_ms(void)
Return the number of milliseconds since the Unix epoch.
Definition: date.c:437
static const char * timestamp(time_t stamp)
Create a YYYY-MM-DD HH:MM:SS timestamp.
Definition: logging.c:77
String manipulation buffer.
Definition: buffer.h:34
List of recognised Timezones.
Definition: date.h:45
unsigned char zminutes
Minutes away from UTC.
Definition: date.h:48
bool zoccident
True if west of UTC, False if East.
Definition: date.h:49
char tzname[8]
Name, e.g. UTC.
Definition: date.h:46
unsigned char zhours
Hours away from UTC.
Definition: date.h:47