Go to the documentation of this file.
49 "Sun",
"Mon",
"Tue",
"Wed",
"Thu",
"Fri",
"Sat",
55 static const char *
const Months[] = {
56 "Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
57 "Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"
66 {
"aat", 1, 0,
true },
67 {
"adt", 4, 0,
false },
68 {
"ast", 3, 0,
false },
70 {
"bst", 1, 0,
false },
71 {
"cat", 1, 0,
false },
72 {
"cdt", 5, 0,
true },
73 {
"cest", 2, 0,
false },
74 {
"cet", 1, 0,
false },
75 {
"cst", 6, 0,
true },
78 {
"eat", 3, 0,
false },
79 {
"edt", 4, 0,
true },
80 {
"eest", 3, 0,
false },
81 {
"eet", 2, 0,
false },
82 {
"egst", 0, 0,
false },
83 {
"egt", 1, 0,
true },
84 {
"est", 5, 0,
true },
85 {
"gmt", 0, 0,
false },
86 {
"gst", 4, 0,
false },
87 {
"hkt", 8, 0,
false },
88 {
"ict", 7, 0,
false },
89 {
"idt", 3, 0,
false },
90 {
"ist", 2, 0,
false },
92 {
"jst", 9, 0,
false },
93 {
"kst", 9, 0,
false },
94 {
"mdt", 6, 0,
true },
95 {
"met", 1, 0,
false },
96 {
"met dst", 2, 0,
false },
97 {
"msd", 4, 0,
false },
98 {
"msk", 3, 0,
false },
99 {
"mst", 7, 0,
true },
100 {
"nzdt", 13, 0,
false },
101 {
"nzst", 12, 0,
false },
102 {
"pdt", 7, 0,
true },
103 {
"pst", 8, 0,
true },
104 {
"sat", 2, 0,
false },
105 {
"smt", 4, 0,
false },
106 {
"sst", 11, 0,
true },
108 {
"utc", 0, 0,
false },
109 {
"wat", 0, 0,
false },
110 {
"west", 1, 0,
false },
111 {
"wet", 0, 0,
false },
112 {
"wgst", 2, 0,
true },
113 {
"wgt", 3, 0,
true },
114 {
"wst", 8, 0,
false },
131 time_t t = (((lt.tm_hour - utc->tm_hour) * 60) + (lt.tm_min - utc->tm_min)) * 60;
133 int yday = (lt.tm_yday - utc->tm_yday);
162 return t + (w ? 1 : -1) * (((time_t) h * 3600) + ((time_t) m * 60));
174 static const struct Tz *
find_tz(
const char *s,
size_t len)
194 int y = tm->tm_year + 1900;
195 return ((y & 3) == 0) && (((y % 100) != 0) || ((y % 400) == 0));
235 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334,
239 if (t->tm_year > 10000)
241 if (t->tm_year < -10000)
244 if ((t->tm_mday < 1) || (t->tm_mday > 31))
246 if ((t->tm_hour < 0) || (t->tm_hour > 23) || (t->tm_min < 0) ||
247 (t->tm_min > 59) || (t->tm_sec < 0) || (t->tm_sec > 60))
251 if (t->tm_year > 9999)
260 if ((t->tm_year % 4) || (t->tm_mon < 2))
265 g += (t->tm_year - 70) * (time_t) 365;
266 g += (t->tm_year - 69) / 4;
301 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
305 while (tm->tm_sec < 0)
310 while (tm->tm_sec >= 60)
315 while (tm->tm_min < 0)
320 while (tm->tm_min >= 60)
325 while (tm->tm_hour < 0)
330 while (tm->tm_hour >= 24)
336 while (tm->tm_mon < 0)
341 while (tm->tm_mon >= 12)
346 while (tm->tm_mday <= 0)
357 while (tm->tm_mday > (DaysPerMonth[tm->tm_mon] + (leap =
is_leap_year_feb(tm))))
359 tm->tm_mday -= DaysPerMonth[tm->tm_mon] + leap;
390 tm.tm_year + 1900, tm.tm_hour, tm.tm_min, tm.tm_sec,
391 (
int) tz / 60, (
int) abs((
int) tz) % 60);
427 struct timeval tv = { 0, 0 };
428 gettimeofday(&tv, NULL);
431 return (uint64_t) tv.tv_sec * 1000 + tv.tv_usec / 1000;
465 struct tm tm = { 0 };
490 else if (tm.tm_year >= 1900)
494 int hour, min, sec = 0;
499 if ((hour > 23) || (min > 59) || (sec > 60))
508 bool zoccident =
false;
513 zoccident = (direction ==
'-');
517 const struct Tz *tz =
556 return snprintf(buf, buflen,
"%02d-%s-%d %02d:%02d:%02d %+03d%02d",
557 tm.tm_mday,
Months[tm.tm_mon], tm.tm_year + 1900, tm.tm_hour,
558 tm.tm_min, tm.tm_sec, (
int) tz / 60, (
int) abs((
int) tz) % 60);
578 return snprintf(buf, buflen,
"%s, %d %s %d %02d:%02d:%02d UTC",
580 tm.tm_year + 1900, tm.tm_hour, tm.tm_min, tm.tm_sec);
610 int zhours, zminutes;
612 bool zoccident = (direction ==
'-');
633 return now + timeout;
645 struct tm tm = { 0 };
650 localtime_r(&t, &tm);
663 struct tm tm = { 0 };
686 return strftime(buf, buflen, format, &tm);
697 .tv_nsec = (ms % 1000) * 1000000UL,
699 nanosleep(&sleep, NULL);
@ PREX_RFC5322_DATE_MATCH_SECOND
Tue, 3 Mar 2020 14:32:[55] +0200
char tzname[8]
Name, e.g. UTC.
@ PREX_RFC5322_DATE_MATCH_TZ
Tue, 3 Mar 2020 14:32:55 [+0200]
uint64_t mutt_date_epoch_ms(void)
Return the number of milliseconds since the Unix epoch.
void mutt_date_make_date(struct Buffer *buf)
Write a date in RFC822 format to a buffer.
String manipulation buffer.
@ PREX_RFC5322_DATE_MATCH_MINUTE
Tue, 3 Mar 2020 14:[32]:55 +0200
@ PREX_RFC5322_DATE_MATCH_TZ_OBS
Tue, 3 Mar 2020 14:32:55[UT]
int mutt_buffer_add_printf(struct Buffer *buf, const char *fmt,...)
Format a string appending a Buffer.
int mutt_date_make_tls(char *buf, size_t buflen, time_t timestamp)
Format date in TLS certificate verification style.
time_t mutt_date_parse_date(const char *s, struct Tz *tz_out)
Parse a date string in RFC822 format.
@ LL_DEBUG1
Log at debug level 1.
@ PREX_RFC5322_DATE_MATCH_YEAR
Tue, 3 Mar [2020] 14:32:55 +0200
@ PREX_RFC5322_DATE_LAX_MATCH_MINUTE
Tue, 3 Mar 2020 14:[32]:55 +0200
@ PREX_RFC5322_DATE_LAX
[Mon, (Comment) 16 Mar 2020 15:09:35 -0700]
@ PREX_RFC5322_DATE_LAX_MATCH_TZ
Tue, 3 Mar 2020 14:32:55 [+0200]
@ PREX_RFC5322_DATE_MATCH_HOUR
Tue, 3 Mar 2020 [14]:32:55 +0200
@ PREX_RFC5322_DATE_LAX_MATCH_SECOND
Tue, 3 Mar 2020 14:32:[55] +0200
@ PREX_RFC5322_DATE_MATCH_DAY
Tue, [3] Mar 2020 14:32:55 +0200
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.
#define mutt_array_size(x)
@ PREX_IMAP_DATE_MATCH_DAY
[ 4]-MAR-2020 15:09:35 -0700
static time_t add_tz_offset(time_t t, bool w, time_t h, time_t m)
Compute and add a timezone offset to an UTC time.
time_t mutt_date_parse_imap(const char *s)
Parse date of the form: DD-MMM-YYYY HH:MM:SS +ZZzz.
static const char *const Months[]
Months of the year (abbreviated)
static const char *const Weekdays[]
Day of the week (abbreviated)
static const char * timestamp(time_t stamp)
Create a YYYY-MM-DD HH:MM:SS timestamp.
@ PREX_IMAP_DATE_MATCH_TZ
15-MAR-2020 15:09:35 [-0700]
unsigned char zhours
Hours away from UTC.
static const struct Tz * find_tz(const char *s, size_t len)
Look up a timezone.
time_t mutt_date_make_time(struct tm *t, bool local)
Convert struct tm to time_t
static const struct Tz TimeZones[]
Lookup table of Time Zones.
size_t mutt_date_localtime_format(char *buf, size_t buflen, const char *format, time_t t)
Format localtime.
static regoff_t mutt_regmatch_start(const regmatch_t *match)
Return the start of a match.
int mutt_date_check_month(const char *s)
Is the string a valid month name.
@ PREX_RFC5322_DATE_LAX_MATCH_YEAR
Tue, 3 Mar [2020] 14:32:55 +0200
static size_t mutt_regmatch_len(const regmatch_t *match)
Return the length of a match.
struct tm mutt_date_localtime(time_t t)
Converts calendar time to a broken-down time structure expressed in user timezone.
time_t mutt_date_local_tz(time_t t)
Calculate the local timezone in seconds east of UTC.
@ PREX_RFC5322_DATE
[Mon, 16 Mar 2020 15:09:35 -0700]
@ PREX_IMAP_DATE_MATCH_TIME
15-MAR-2020 [15:09:35] -0700
void mutt_date_sleep_ms(size_t ms)
Sleep for milliseconds.
#define mutt_debug(LEVEL,...)
static int is_leap_year_feb(struct tm *tm)
Is a given February in a leap year.
@ PREX_IMAP_DATE_MATCH_YEAR
15-MAR-[2020] 15:09:35 -0700
time_t mutt_date_epoch(void)
Return the number of seconds since the Unix epoch.
#define MUTT_DATE_NOW
Constant representing the 'current time', see: mutt_date_gmtime(), mutt_date_localtime()
@ PREX_RFC5322_DATE_MATCH_MONTH
Tue, 3 [Jan] 2020 14:32:55 +0200
@ PREX_RFC5322_DATE_LAX_MATCH_HOUR
Tue, 3 Mar 2020 [14]:32:55 +0200
unsigned char zminutes
Minutes away from UTC.
size_t mutt_istr_startswith(const char *str, const char *prefix)
Check whether a string starts with a prefix, ignoring case.
struct tm mutt_date_gmtime(time_t t)
Converts calendar time to a broken-down time structure expressed in UTC timezone.
bool mutt_istrn_equal(const char *a, const char *b, size_t num)
Check for equality of two strings ignoring case (to a maximum), safely.
static time_t compute_tz(time_t g, struct tm *utc)
Calculate the number of seconds east of UTC.
time_t mutt_date_add_timeout(time_t now, time_t timeout)
Safely add a timeout to a given time_t value.
Time value with nanosecond precision.
@ PREX_RFC5322_DATE_LAX_MATCH_MONTH
Tue, 3 [Jan] 2020 14:32:55 +0200
List of recognised Timezones.
@ PREX_RFC5322_DATE_LAX_MATCH_TZ_OBS
Tue, 3 Mar 2020 14:32:55[UT]
@ PREX_IMAP_DATE
[16-MAR-2020 15:09:35 -0700]
bool zoccident
True if west of UTC, False if East.
@ PREX_IMAP_DATE_MATCH_MONTH
15-[MAR]-2020 15:09:35 -0700
@ LL_DEBUG2
Log at debug level 2.
void mutt_date_normalize_time(struct tm *tm)
Fix the contents of a struct tm.
@ PREX_RFC5322_DATE_LAX_MATCH_DAY
Tue, [3] Mar 2020 14:32:55 +0200
regmatch_t * mutt_prex_capture(enum Prex which, const char *str)