NeoMutt  2020-06-26-89-g172cd3
Teaching an old dog new tricks
DOXYGEN
date.c
Go to the documentation of this file.
1 
29 #include "config.h"
30 #include <stdbool.h>
31 #include <stdint.h>
32 #include <stdio.h>
33 #include <stdlib.h>
34 #include <sys/time.h>
35 #include <time.h>
36 #include "date.h"
37 #include "logging.h"
38 #include "memory.h"
39 #include "prex.h"
40 #include "regex3.h"
41 #include "string2.h"
42 
43 // clang-format off
47 static const char *const Weekdays[] = {
48  "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat",
49 };
50 
54 static const char *const Months[] = {
55  "Jan", "Feb", "Mar", "Apr", "May", "Jun",
56  "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
57 };
58 
64 static const struct Tz TimeZones[] = {
65  { "aat", 1, 0, true }, /* Atlantic Africa Time */
66  { "adt", 4, 0, false }, /* Arabia DST */
67  { "ast", 3, 0, false }, /* Arabia */
68 //{ "ast", 4, 0, true }, /* Atlantic */
69  { "bst", 1, 0, false }, /* British DST */
70  { "cat", 1, 0, false }, /* Central Africa */
71  { "cdt", 5, 0, true },
72  { "cest", 2, 0, false }, /* Central Europe DST */
73  { "cet", 1, 0, false }, /* Central Europe */
74  { "cst", 6, 0, true },
75 //{ "cst", 8, 0, false }, /* China */
76 //{ "cst", 9, 30, false }, /* Australian Central Standard Time */
77  { "eat", 3, 0, false }, /* East Africa */
78  { "edt", 4, 0, true },
79  { "eest", 3, 0, false }, /* Eastern Europe DST */
80  { "eet", 2, 0, false }, /* Eastern Europe */
81  { "egst", 0, 0, false }, /* Eastern Greenland DST */
82  { "egt", 1, 0, true }, /* Eastern Greenland */
83  { "est", 5, 0, true },
84  { "gmt", 0, 0, false },
85  { "gst", 4, 0, false }, /* Presian Gulf */
86  { "hkt", 8, 0, false }, /* Hong Kong */
87  { "ict", 7, 0, false }, /* Indochina */
88  { "idt", 3, 0, false }, /* Israel DST */
89  { "ist", 2, 0, false }, /* Israel */
90 //{ "ist", 5, 30, false }, /* India */
91  { "jst", 9, 0, false }, /* Japan */
92  { "kst", 9, 0, false }, /* Korea */
93  { "mdt", 6, 0, true },
94  { "met", 1, 0, false }, /* This is now officially CET */
95  { "met dst", 2, 0, false }, /* MET in Daylight Saving Time */
96  { "msd", 4, 0, false }, /* Moscow DST */
97  { "msk", 3, 0, false }, /* Moscow */
98  { "mst", 7, 0, true },
99  { "nzdt", 13, 0, false }, /* New Zealand DST */
100  { "nzst", 12, 0, false }, /* New Zealand */
101  { "pdt", 7, 0, true },
102  { "pst", 8, 0, true },
103  { "sat", 2, 0, false }, /* South Africa */
104  { "smt", 4, 0, false }, /* Seychelles */
105  { "sst", 11, 0, true }, /* Samoa */
106 //{ "sst", 8, 0, false }, /* Singapore */
107  { "utc", 0, 0, false },
108  { "wat", 0, 0, false }, /* West Africa */
109  { "west", 1, 0, false }, /* Western Europe DST */
110  { "wet", 0, 0, false }, /* Western Europe */
111  { "wgst", 2, 0, true }, /* Western Greenland DST */
112  { "wgt", 3, 0, true }, /* Western Greenland */
113  { "wst", 8, 0, false }, /* Western Australia */
114 };
115 // clang-format on
116 
126 static time_t compute_tz(time_t g, struct tm *utc)
127 {
128  struct tm lt = mutt_date_localtime(g);
129 
130  time_t t = (((lt.tm_hour - utc->tm_hour) * 60) + (lt.tm_min - utc->tm_min)) * 60;
131 
132  int yday = (lt.tm_yday - utc->tm_yday);
133  if (yday != 0)
134  {
135  /* This code is optimized to negative timezones (West of Greenwich) */
136  if ((yday == -1) || /* UTC passed midnight before localtime */
137  (yday > 1)) /* UTC passed new year before localtime */
138  {
139  t -= (24 * 60 * 60);
140  }
141  else
142  {
143  t += (24 * 60 * 60);
144  }
145  }
146 
147  return t;
148 }
149 
158 static time_t add_tz_offset(time_t t, bool w, time_t h, time_t m)
159 {
160  if ((t != TIME_T_MAX) && (t != TIME_T_MIN))
161  return t + (w ? 1 : -1) * (((time_t) h * 3600) + ((time_t) m * 60));
162  else
163  return t;
164 }
165 
173 static const struct Tz *find_tz(const char *s, size_t len)
174 {
175  for (size_t i = 0; i < mutt_array_size(TimeZones); i++)
176  {
177  if (mutt_istrn_equal(TimeZones[i].tzname, s, len))
178  return &TimeZones[i];
179  }
180  return NULL;
181 }
182 
188 static int is_leap_year_feb(struct tm *tm)
189 {
190  if (tm->tm_mon != 1)
191  return 0;
192 
193  int y = tm->tm_year + 1900;
194  return ((y & 3) == 0) && (((y % 100) != 0) || ((y % 400) == 0));
195 }
196 
205 time_t mutt_date_local_tz(time_t t)
206 {
207  /* Check we haven't overflowed the time (on 32-bit arches) */
208  if ((t == TIME_T_MAX) || (t == TIME_T_MIN))
209  return 0;
210 
211  if (t == 0)
212  t = mutt_date_epoch();
213 
214  struct tm tm = mutt_date_gmtime(t);
215  return compute_tz(t, &tm);
216 }
217 
228 time_t mutt_date_make_time(struct tm *t, bool local)
229 {
230  if (!t)
231  return TIME_T_MIN;
232 
233  static const int AccumDaysPerMonth[mutt_array_size(Months)] = {
234  0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334,
235  };
236 
237  /* Prevent an integer overflow, with some arbitrary limits. */
238  if (t->tm_year > 10000)
239  return TIME_T_MAX;
240  if (t->tm_year < -10000)
241  return TIME_T_MIN;
242 
243  if ((t->tm_mday < 1) || (t->tm_mday > 31))
244  return TIME_T_MIN;
245  if ((t->tm_hour < 0) || (t->tm_hour > 23) || (t->tm_min < 0) ||
246  (t->tm_min > 59) || (t->tm_sec < 0) || (t->tm_sec > 60))
247  {
248  return TIME_T_MIN;
249  }
250  if (t->tm_year > 9999)
251  return TIME_T_MAX;
252 
253  /* Compute the number of days since January 1 in the same year */
254  time_t g = AccumDaysPerMonth[t->tm_mon % mutt_array_size(Months)];
255 
256  /* The leap years are 1972 and every 4. year until 2096,
257  * but this algorithm will fail after year 2099 */
258  g += t->tm_mday;
259  if ((t->tm_year % 4) || (t->tm_mon < 2))
260  g--;
261  t->tm_yday = g;
262 
263  /* Compute the number of days since January 1, 1970 */
264  g += (t->tm_year - 70) * (time_t) 365;
265  g += (t->tm_year - 69) / 4;
266 
267  /* Compute the number of hours */
268  g *= 24;
269  g += t->tm_hour;
270 
271  /* Compute the number of minutes */
272  g *= 60;
273  g += t->tm_min;
274 
275  /* Compute the number of seconds */
276  g *= 60;
277  g += t->tm_sec;
278 
279  if (local)
280  g -= compute_tz(g, t);
281 
282  return g;
283 }
284 
294 void mutt_date_normalize_time(struct tm *tm)
295 {
296  if (!tm)
297  return;
298 
299  static const char DaysPerMonth[mutt_array_size(Months)] = {
300  31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
301  };
302  int leap;
303 
304  while (tm->tm_sec < 0)
305  {
306  tm->tm_sec += 60;
307  tm->tm_min--;
308  }
309  while (tm->tm_sec >= 60)
310  {
311  tm->tm_sec -= 60;
312  tm->tm_min++;
313  }
314  while (tm->tm_min < 0)
315  {
316  tm->tm_min += 60;
317  tm->tm_hour--;
318  }
319  while (tm->tm_min >= 60)
320  {
321  tm->tm_min -= 60;
322  tm->tm_hour++;
323  }
324  while (tm->tm_hour < 0)
325  {
326  tm->tm_hour += 24;
327  tm->tm_mday--;
328  }
329  while (tm->tm_hour >= 24)
330  {
331  tm->tm_hour -= 24;
332  tm->tm_mday++;
333  }
334  /* use loops on NNNdwmy user input values? */
335  while (tm->tm_mon < 0)
336  {
337  tm->tm_mon += 12;
338  tm->tm_year--;
339  }
340  while (tm->tm_mon >= 12)
341  {
342  tm->tm_mon -= 12;
343  tm->tm_year++;
344  }
345  while (tm->tm_mday <= 0)
346  {
347  if (tm->tm_mon)
348  tm->tm_mon--;
349  else
350  {
351  tm->tm_mon = 11;
352  tm->tm_year--;
353  }
354  tm->tm_mday += DaysPerMonth[tm->tm_mon] + is_leap_year_feb(tm);
355  }
356  while (tm->tm_mday > (DaysPerMonth[tm->tm_mon] + (leap = is_leap_year_feb(tm))))
357  {
358  tm->tm_mday -= DaysPerMonth[tm->tm_mon] + leap;
359  if (tm->tm_mon < 11)
360  tm->tm_mon++;
361  else
362  {
363  tm->tm_mon = 0;
364  tm->tm_year++;
365  }
366  }
367 }
368 
375 char *mutt_date_make_date(char *buf, size_t buflen)
376 {
377  if (!buf)
378  return NULL;
379 
380  time_t t = mutt_date_epoch();
381  struct tm tm = mutt_date_localtime(t);
382  time_t tz = mutt_date_local_tz(t);
383 
384  tz /= 60;
385 
386  snprintf(buf, buflen, "Date: %s, %d %s %d %02d:%02d:%02d %+03d%02d\n",
387  Weekdays[tm.tm_wday], tm.tm_mday, Months[tm.tm_mon], tm.tm_year + 1900,
388  tm.tm_hour, tm.tm_min, tm.tm_sec, (int) tz / 60, (int) abs((int) tz) % 60);
389  return buf;
390 }
391 
401 int mutt_date_check_month(const char *s)
402 {
403  for (int i = 0; i < mutt_array_size(Months); i++)
404  if (mutt_istr_startswith(s, Months[i]))
405  return i;
406 
407  return -1; /* error */
408 }
409 
414 time_t mutt_date_epoch(void)
415 {
416  return mutt_date_epoch_ms() / 1000;
417 }
418 
423 uint64_t mutt_date_epoch_ms(void)
424 {
425  struct timeval tv = { 0, 0 };
426  gettimeofday(&tv, NULL);
427  /* We assume that gettimeofday doesn't modify its first argument on failure.
428  * We also kind of assume that gettimeofday does not fail. */
429  return (uint64_t) tv.tv_sec * 1000 + tv.tv_usec / 1000;
430 }
431 
443 time_t mutt_date_parse_date(const char *s, struct Tz *tz_out)
444 {
445  if (!s)
446  return -1;
447 
448  bool lax = false;
449 
450  const regmatch_t *match = mutt_prex_capture(PREX_RFC5322_DATE, s);
451  if (!match)
452  {
454  if (!match)
455  {
456  mutt_debug(LL_DEBUG1, "Could not parse date: <%s>\n", s);
457  return -1;
458  }
459  lax = true;
460  mutt_debug(LL_DEBUG2, "Fallback regex for date: <%s>\n", s);
461  }
462 
463  struct tm tm = { 0 };
464 
465  // clang-format off
466  const regmatch_t *mday = &match[lax ? PREX_RFC5322_DATE_LAX_MATCH_DAY : PREX_RFC5322_DATE_MATCH_DAY];
467  const regmatch_t *mmonth = &match[lax ? PREX_RFC5322_DATE_LAX_MATCH_MONTH : PREX_RFC5322_DATE_MATCH_MONTH];
468  const regmatch_t *myear = &match[lax ? PREX_RFC5322_DATE_LAX_MATCH_YEAR : PREX_RFC5322_DATE_MATCH_YEAR];
469  const regmatch_t *mhour = &match[lax ? PREX_RFC5322_DATE_LAX_MATCH_HOUR : PREX_RFC5322_DATE_MATCH_HOUR];
470  const regmatch_t *mminute = &match[lax ? PREX_RFC5322_DATE_LAX_MATCH_MINUTE : PREX_RFC5322_DATE_MATCH_MINUTE];
471  const regmatch_t *msecond = &match[lax ? PREX_RFC5322_DATE_LAX_MATCH_SECOND : PREX_RFC5322_DATE_MATCH_SECOND];
472  const regmatch_t *mtz = &match[lax ? PREX_RFC5322_DATE_LAX_MATCH_TZ : PREX_RFC5322_DATE_MATCH_TZ];
473  const regmatch_t *mtzobs = &match[lax ? PREX_RFC5322_DATE_LAX_MATCH_TZ_OBS : PREX_RFC5322_DATE_MATCH_TZ_OBS];
474  // clang-format on
475 
476  /* Day */
477  sscanf(s + mutt_regmatch_start(mday), "%d", &tm.tm_mday);
478  if (tm.tm_mday > 31)
479  return -1;
480 
481  /* Month */
482  tm.tm_mon = mutt_date_check_month(s + mutt_regmatch_start(mmonth));
483 
484  /* Year */
485  sscanf(s + mutt_regmatch_start(myear), "%d", &tm.tm_year);
486  if (tm.tm_year < 50)
487  tm.tm_year += 100;
488  else if (tm.tm_year >= 1900)
489  tm.tm_year -= 1900;
490 
491  /* Time */
492  int hour, min, sec = 0;
493  sscanf(s + mutt_regmatch_start(mhour), "%d", &hour);
494  sscanf(s + mutt_regmatch_start(mminute), "%d", &min);
495  if (mutt_regmatch_start(msecond) != -1)
496  sscanf(s + mutt_regmatch_start(msecond), "%d", &sec);
497  if ((hour > 23) || (min > 59) || (sec > 60))
498  return -1;
499  tm.tm_hour = hour;
500  tm.tm_min = min;
501  tm.tm_sec = sec;
502 
503  /* Time zone */
504  int zhours = 0;
505  int zminutes = 0;
506  bool zoccident = false;
507  if (mutt_regmatch_start(mtz) != -1)
508  {
509  char direction;
510  sscanf(s + mutt_regmatch_start(mtz), "%c%02d%02d", &direction, &zhours, &zminutes);
511  zoccident = (direction == '-');
512  }
513  else if (mutt_regmatch_start(mtzobs) != -1)
514  {
515  const struct Tz *tz =
516  find_tz(s + mutt_regmatch_start(mtzobs), mutt_regmatch_len(mtzobs));
517  if (tz)
518  {
519  zhours = tz->zhours;
520  zminutes = tz->zminutes;
521  zoccident = tz->zoccident;
522  }
523  }
524 
525  if (tz_out)
526  {
527  tz_out->zhours = zhours;
528  tz_out->zminutes = zminutes;
529  tz_out->zoccident = zoccident;
530  }
531 
532  return add_tz_offset(mutt_date_make_time(&tm, false), zoccident, zhours, zminutes);
533 }
534 
544 int mutt_date_make_imap(char *buf, size_t buflen, time_t timestamp)
545 {
546  if (!buf)
547  return -1;
548 
549  struct tm tm = mutt_date_localtime(timestamp);
550  time_t tz = mutt_date_local_tz(timestamp);
551 
552  tz /= 60;
553 
554  return snprintf(buf, buflen, "%02d-%s-%d %02d:%02d:%02d %+03d%02d",
555  tm.tm_mday, Months[tm.tm_mon], tm.tm_year + 1900, tm.tm_hour,
556  tm.tm_min, tm.tm_sec, (int) tz / 60, (int) abs((int) tz) % 60);
557 }
558 
570 int mutt_date_make_tls(char *buf, size_t buflen, time_t timestamp)
571 {
572  if (!buf)
573  return -1;
574 
575  struct tm tm = mutt_date_gmtime(timestamp);
576  return snprintf(buf, buflen, "%s, %d %s %d %02d:%02d:%02d UTC",
577  Weekdays[tm.tm_wday], tm.tm_mday, Months[tm.tm_mon],
578  tm.tm_year + 1900, tm.tm_hour, tm.tm_min, tm.tm_sec);
579 }
580 
587 time_t mutt_date_parse_imap(const char *s)
588 {
589  const regmatch_t *match = mutt_prex_capture(PREX_IMAP_DATE, s);
590  if (!match)
591  return 0;
592 
593  const regmatch_t *mday = &match[PREX_IMAP_DATE_MATCH_DAY];
594  const regmatch_t *mmonth = &match[PREX_IMAP_DATE_MATCH_MONTH];
595  const regmatch_t *myear = &match[PREX_IMAP_DATE_MATCH_YEAR];
596  const regmatch_t *mtime = &match[PREX_IMAP_DATE_MATCH_TIME];
597  const regmatch_t *mtz = &match[PREX_IMAP_DATE_MATCH_TZ];
598 
599  struct tm tm;
600 
601  sscanf(s + mutt_regmatch_start(mday), " %d", &tm.tm_mday);
602  tm.tm_mon = mutt_date_check_month(s + mutt_regmatch_start(mmonth));
603  sscanf(s + mutt_regmatch_start(myear), "%d", &tm.tm_year);
604  tm.tm_year -= 1900;
605  sscanf(s + mutt_regmatch_start(mtime), "%d:%d:%d", &tm.tm_hour, &tm.tm_min, &tm.tm_sec);
606 
607  char direction;
608  int zhours, zminutes;
609  sscanf(s + mutt_regmatch_start(mtz), "%c%02d%02d", &direction, &zhours, &zminutes);
610  bool zoccident = (direction == '-');
611 
612  return add_tz_offset(mutt_date_make_time(&tm, false), zoccident, zhours, zminutes);
613 }
614 
623 time_t mutt_date_add_timeout(time_t now, time_t timeout)
624 {
625  if (timeout < 0)
626  return now;
627 
628  if ((TIME_T_MAX - now) < timeout)
629  return TIME_T_MAX;
630 
631  return now + timeout;
632 }
633 
641 struct tm mutt_date_localtime(time_t t)
642 {
643  struct tm tm = { 0 };
644 
645  if (t == MUTT_DATE_NOW)
646  t = mutt_date_epoch();
647 
648  localtime_r(&t, &tm);
649  return tm;
650 }
651 
659 struct tm mutt_date_gmtime(time_t t)
660 {
661  struct tm tm = { 0 };
662 
663  if (t == MUTT_DATE_NOW)
664  t = mutt_date_epoch();
665 
666  gmtime_r(&t, &tm);
667  return tm;
668 }
669 
678 size_t mutt_date_localtime_format(char *buf, size_t buflen, const char *format, time_t t)
679 {
680  if (!buf || !format)
681  return 0;
682 
683  struct tm tm = mutt_date_localtime(t);
684  return strftime(buf, buflen, format, &tm);
685 }
686 
691 void mutt_date_sleep_ms(size_t ms)
692 {
693  const struct timespec sleep = {
694  .tv_sec = ms / 1000,
695  .tv_nsec = (ms % 1000) * 1000000UL,
696  };
697  nanosleep(&sleep, NULL);
698 }
time_t mutt_date_epoch(void)
Return the number of seconds since the Unix epoch.
Definition: date.c:414
Tue, 3 Mar [2020] 14:32:55 +0200
Definition: prex.h:127
#define TIME_T_MIN
Definition: date.h:32
uint64_t mutt_date_epoch_ms(void)
Return the number of milliseconds since the Unix epoch.
Definition: date.c:423
Manage precompiled / predefined regular expressions.
size_t mutt_date_localtime_format(char *buf, size_t buflen, const char *format, time_t t)
Format localtime.
Definition: date.c:678
Tue, [3] Mar 2020 14:32:55 +0200
Definition: prex.h:125
Memory management wrappers.
struct tm mutt_date_localtime(time_t t)
Converts calendar time to a broken-down time structure expressed in user timezone.
Definition: date.c:641
#define TIME_T_MAX
Definition: date.h:31
Tue, 3 Mar 2020 14:32:55[UT]
Definition: prex.h:172
[16-MAR-2020 15:09:35 -0700]
Definition: prex.h:39
Tue, 3 Mar 2020 14:32:[55] +0200
Definition: prex.h:168
static const char *const Months[]
Months of the year (abbreviated)
Definition: date.c:54
static size_t mutt_regmatch_len(const regmatch_t *match)
Return the length of a match.
Definition: regex3.h:80
void mutt_date_normalize_time(struct tm *tm)
Fix the contents of a struct tm.
Definition: date.c:294
static const char * timestamp(time_t stamp)
Create a YYYY-MM-DD HH:MM:SS timestamp.
Definition: logging.c:77
Tue, [3] Mar 2020 14:32:55 +0200
Definition: prex.h:156
#define MUTT_DATE_NOW
Constant representing the &#39;current time&#39;, see: mutt_date_gmtime(), mutt_date_localtime() ...
Definition: date.h:37
15-MAR-2020 15:09:35 [-0700]
Definition: prex.h:190
struct tm mutt_date_gmtime(time_t t)
Converts calendar time to a broken-down time structure expressed in UTC timezone. ...
Definition: date.c:659
time_t mutt_date_local_tz(time_t t)
Calculate the local timezone in seconds east of UTC.
Definition: date.c:205
15-MAR-2020 [15:09:35] -0700
Definition: prex.h:189
time_t mutt_date_parse_date(const char *s, struct Tz *tz_out)
Parse a date string in RFC822 format.
Definition: date.c:443
static int is_leap_year_feb(struct tm *tm)
Is a given February in a leap year.
Definition: date.c:188
Tue, 3 Mar 2020 14:[32]:55 +0200
Definition: prex.h:129
Tue, 3 Mar [2020] 14:32:55 +0200
Definition: prex.h:160
unsigned char zhours
Hours away from UTC.
Definition: date.h:45
char tzname[8]
Name, e.g. UTC.
Definition: date.h:44
Tue, 3 Mar 2020 14:32:55 [+0200]
Definition: prex.h:133
char * mutt_date_make_date(char *buf, size_t buflen)
Write a date in RFC822 format to a buffer.
Definition: date.c:375
Logging Dispatcher.
15-MAR-[2020] 15:09:35 -0700
Definition: prex.h:188
time_t tv_sec
Definition: file.h:48
String manipulation functions.
bool mutt_istrn_equal(const char *a, const char *b, size_t l)
Check for equality of two strings ignoring case (to a maximum), safely.
Definition: string.c:626
#define mutt_array_size(x)
Definition: memory.h:33
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:623
Tue, 3 [Jan] 2020 14:32:55 +0200
Definition: prex.h:126
int mutt_date_make_tls(char *buf, size_t buflen, time_t timestamp)
Format date in TLS certificate verification style.
Definition: date.c:570
Log at debug level 2.
Definition: logging.h:41
Tue, 3 Mar 2020 14:[32]:55 +0200
Definition: prex.h:164
[Mon, (Comment) 16 Mar 2020 15:09:35 -0700]
Definition: prex.h:38
bool zoccident
True if west of UTC, False if East.
Definition: date.h:47
Tue, 3 Mar 2020 14:32:55 [+0200]
Definition: prex.h:171
Tue, 3 Mar 2020 [14]:32:55 +0200
Definition: prex.h:128
[ 4]-MAR-2020 15:09:35 -0700
Definition: prex.h:184
regmatch_t * mutt_prex_capture(enum Prex which, const char *str)
match a precompiled regex against a string
Definition: prex.c:306
static const struct Tz * find_tz(const char *s, size_t len)
Look up a timezone.
Definition: date.c:173
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.
Definition: date.c:158
static regoff_t mutt_regmatch_start(const regmatch_t *match)
Return the start of a match.
Definition: regex3.h:60
Tue, 3 [Jan] 2020 14:32:55 +0200
Definition: prex.h:158
size_t mutt_istr_startswith(const char *str, const char *prefix)
Check whether a string starts with a prefix, ignoring case.
Definition: string.c:177
[Mon, 16 Mar 2020 15:09:35 -0700]
Definition: prex.h:37
static time_t compute_tz(time_t g, struct tm *utc)
Calculate the number of seconds east of UTC.
Definition: date.c:126
15-[MAR]-2020 15:09:35 -0700
Definition: prex.h:187
unsigned char zminutes
Minutes away from UTC.
Definition: date.h:46
List of recognised Timezones.
Definition: date.h:42
Log at debug level 1.
Definition: logging.h:40
Tue, 3 Mar 2020 14:32:[55] +0200
Definition: prex.h:131
int mutt_date_check_month(const char *s)
Is the string a valid month name.
Definition: date.c:401
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:544
Time value with nanosecond precision.
Definition: file.h:46
Manage regular expressions.
#define mutt_debug(LEVEL,...)
Definition: logging.h:81
time_t mutt_date_parse_imap(const char *s)
Parse date of the form: DD-MMM-YYYY HH:MM:SS +ZZzz.
Definition: date.c:587
static const char *const Weekdays[]
Day of the week (abbreviated)
Definition: date.c:47
Time and date handling routines.
time_t mutt_date_make_time(struct tm *t, bool local)
Convert struct tm to time_t
Definition: date.c:228
Tue, 3 Mar 2020 [14]:32:55 +0200
Definition: prex.h:162
void mutt_date_sleep_ms(size_t ms)
Sleep for milliseconds.
Definition: date.c:691
Tue, 3 Mar 2020 14:32:55[UT]
Definition: prex.h:134