NeoMutt  2023-05-17-33-gce4425
Teaching an old dog new tricks
DOXYGEN
date.h
Go to the documentation of this file.
1
23#ifndef MUTT_MUTT_DATE_H
24#define MUTT_MUTT_DATE_H
25
26#include <stdbool.h>
27#include <stdint.h>
28#include <time.h>
29
30struct Buffer;
31
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)
38
42struct Tz
43{
44 char tzname[8];
45 unsigned char zhours;
46 unsigned char zminutes;
47 bool zoccident;
48};
49
50time_t mutt_date_add_timeout(time_t now, time_t timeout);
51int mutt_date_check_month(const char *s);
52time_t mutt_date_now(void);
53uint64_t mutt_date_now_ms(void);
54struct tm mutt_date_gmtime(time_t t);
55size_t mutt_date_localtime_format(char *buf, size_t buflen, const char *format, time_t t);
56struct tm mutt_date_localtime(time_t t);
57int mutt_date_local_tz(time_t t);
58void mutt_date_make_date(struct Buffer *buf, bool local);
59int mutt_date_make_imap(char *buf, size_t buflen, time_t timestamp);
60time_t mutt_date_make_time(struct tm *t, bool local);
61int mutt_date_make_tls(char *buf, size_t buflen, time_t timestamp);
62void mutt_date_normalize_time(struct tm *tm);
63time_t mutt_date_parse_date(const char *s, struct Tz *tz_out);
64time_t mutt_date_parse_imap(const char *s);
65void mutt_date_sleep_ms(size_t ms);
66
67#endif /* MUTT_MUTT_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:879
size_t mutt_date_localtime_format(char *buf, size_t buflen, const char *format, time_t t)
Format localtime.
Definition: date.c:924
uint64_t mutt_date_now_ms(void)
Return the number of milliseconds since the Unix epoch.
Definition: date.c:455
void mutt_date_make_date(struct Buffer *buf, bool local)
Write a date in RFC822 format to a buffer.
Definition: date.c:387
time_t mutt_date_make_time(struct tm *t, bool local)
Convert struct tm to time_t
Definition: date.c:232
void mutt_date_sleep_ms(size_t ms)
Sleep for milliseconds.
Definition: date.c:937
int mutt_date_check_month(const char *s)
Is the string a valid month name.
Definition: date.c:422
struct tm mutt_date_gmtime(time_t t)
Converts calendar time to a broken-down time structure expressed in UTC timezone.
Definition: date.c:900
int mutt_date_make_tls(char *buf, size_t buflen, time_t timestamp)
Format date in TLS certificate verification style.
Definition: date.c:810
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:784
int mutt_date_local_tz(time_t t)
Calculate the local timezone in seconds east of UTC.
Definition: date.c:209
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:863
time_t mutt_date_now(void)
Return the number of seconds since the Unix epoch.
Definition: date.c:446
time_t mutt_date_parse_date(const char *s, struct Tz *tz_out)
Parse a date string in RFC822 format.
Definition: date.c:686
time_t mutt_date_parse_imap(const char *s)
Parse date of the form: DD-MMM-YYYY HH:MM:SS +ZZzz.
Definition: date.c:827
void mutt_date_normalize_time(struct tm *tm)
Fix the contents of a struct tm.
Definition: date.c:300
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:43
unsigned char zminutes
Minutes away from UTC.
Definition: date.h:46
bool zoccident
True if west of UTC, False if East.
Definition: date.h:47
char tzname[8]
Name, e.g. UTC.
Definition: date.h:44
unsigned char zhours
Hours away from UTC.
Definition: date.h:45