NeoMutt  2024-04-25-89-g194907
Teaching an old dog new tricks
No Matches
Go to the documentation of this file.
25#ifndef MUTT_MUTT_DATE_H
26#define MUTT_MUTT_DATE_H
28#include <locale.h>
29#include <stdbool.h>
30#include <stdint.h>
31#include <time.h>
32#ifdef __APPLE__
33#include <xlocale.h>
36struct Buffer;
37struct timespec;
39/* theoretically time_t can be float but it is integer on most (if not all) systems */
40#define TIME_T_MAX ((((time_t) 1 << (sizeof(time_t) * 8 - 2)) - 1) * 2 + 1)
41#define TIME_T_MIN (-TIME_T_MAX - 1)
42#define TM_YEAR_MAX \
43 (1970 + (((((TIME_T_MAX - 59) / 60) - 59) / 60) - 23) / 24 / 366)
44#define TM_YEAR_MIN (1970 - (TM_YEAR_MAX - 1970) - 1)
49struct Tz
51 char tzname[8];
52 unsigned char zhours;
53 unsigned char zminutes;
54 bool zoccident;
57time_t mutt_date_add_timeout(time_t now, time_t timeout);
58int mutt_date_check_month(const char *s);
59time_t mutt_date_now(void);
60uint64_t mutt_date_now_ms(void);
61struct tm mutt_date_gmtime(time_t t);
62size_t mutt_date_localtime_format(char *buf, size_t buflen, const char *format, time_t t);
63size_t mutt_date_localtime_format_locale(char *buf, size_t buflen, const char *format, time_t t, locale_t loc);
64struct tm mutt_date_localtime(time_t t);
65int mutt_date_local_tz(time_t t);
66void mutt_date_make_date(struct Buffer *buf, bool local);
67int mutt_date_make_imap(struct Buffer *buf, time_t timestamp);
68time_t mutt_date_make_time(struct tm *t, bool local);
69int mutt_date_make_tls(char *buf, size_t buflen, time_t timestamp);
70void mutt_date_normalize_time(struct tm *tm);
71time_t mutt_date_parse_date(const char *s, struct Tz *tz_out);
72time_t mutt_date_parse_imap(const char *s);
73void mutt_date_sleep_ms(size_t ms);
74void mutt_time_now(struct timespec *tp);
76#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:906
size_t mutt_date_localtime_format(char *buf, size_t buflen, const char *format, time_t t)
Format localtime.
Definition: date.c:951
uint64_t mutt_date_now_ms(void)
Return the number of milliseconds since the Unix epoch.
Definition: date.c:465
void mutt_date_make_date(struct Buffer *buf, bool local)
Write a date in RFC822 format to a buffer.
Definition: date.c:397
time_t mutt_date_make_time(struct tm *t, bool local)
Convert struct tm to time_t
Definition: date.c:242
void mutt_date_sleep_ms(size_t ms)
Sleep for milliseconds.
Definition: date.c:983
int mutt_date_check_month(const char *s)
Is the string a valid month name.
Definition: date.c:432
struct tm mutt_date_gmtime(time_t t)
Converts calendar time to a broken-down time structure expressed in UTC timezone.
Definition: date.c:927
size_t mutt_date_localtime_format_locale(char *buf, size_t buflen, const char *format, time_t t, locale_t loc)
Format localtime using a given locale.
Definition: date.c:969
int mutt_date_make_tls(char *buf, size_t buflen, time_t timestamp)
Format date in TLS certificate verification style.
Definition: date.c:837
int mutt_date_make_imap(struct Buffer *buf, time_t timestamp)
Format date in IMAP style: DD-MMM-YYYY HH:MM:SS +ZZzz.
Definition: date.c:811
int mutt_date_local_tz(time_t t)
Calculate the local timezone in seconds east of UTC.
Definition: date.c:219
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:890
time_t mutt_date_now(void)
Return the number of seconds since the Unix epoch.
Definition: date.c:456
time_t mutt_date_parse_date(const char *s, struct Tz *tz_out)
Parse a date string in RFC822 format.
Definition: date.c:716
time_t mutt_date_parse_imap(const char *s)
Parse date of the form: DD-MMM-YYYY HH:MM:SS +ZZzz.
Definition: date.c:854
void mutt_time_now(struct timespec *tp)
Set the provided time field to the current time.
Definition: date.c:480
void mutt_date_normalize_time(struct tm *tm)
Fix the contents of a struct tm.
Definition: date.c:310
static const char * timestamp(time_t stamp)
Create a YYYY-MM-DD HH:MM:SS timestamp.
Definition: logging.c:78
String manipulation buffer.
Definition: buffer.h:36
List of recognised Timezones.
Definition: date.h:50
unsigned char zminutes
Minutes away from UTC.
Definition: date.h:53
bool zoccident
True if west of UTC, False if East.
Definition: date.h:54
char tzname[8]
Name, e.g. UTC.
Definition: date.h:51
unsigned char zhours
Hours away from UTC.
Definition: date.h:52
Time value with nanosecond precision.
Definition: file.h:51