NeoMutt  2023-11-03-85-g512e01
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
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 <locale.h>
27#include <stdbool.h>
28#include <stdint.h>
29#include <time.h>
30#ifdef __APPLE__
31#include <xlocale.h>
32#endif
33
34struct Buffer;
35
36/* theoretically time_t can be float but it is integer on most (if not all) systems */
37#define TIME_T_MAX ((((time_t) 1 << (sizeof(time_t) * 8 - 2)) - 1) * 2 + 1)
38#define TIME_T_MIN (-TIME_T_MAX - 1)
39#define TM_YEAR_MAX \
40 (1970 + (((((TIME_T_MAX - 59) / 60) - 59) / 60) - 23) / 24 / 366)
41#define TM_YEAR_MIN (1970 - (TM_YEAR_MAX - 1970) - 1)
42
46struct Tz
47{
48 char tzname[8];
49 unsigned char zhours;
50 unsigned char zminutes;
51 bool zoccident;
52};
53
54time_t mutt_date_add_timeout(time_t now, time_t timeout);
55int mutt_date_check_month(const char *s);
56time_t mutt_date_now(void);
57uint64_t mutt_date_now_ms(void);
58struct tm mutt_date_gmtime(time_t t);
59size_t mutt_date_localtime_format(char *buf, size_t buflen, const char *format, time_t t);
60size_t mutt_date_localtime_format_locale(char *buf, size_t buflen, const char *format, time_t t, locale_t loc);
61struct tm mutt_date_localtime(time_t t);
62int mutt_date_local_tz(time_t t);
63void mutt_date_make_date(struct Buffer *buf, bool local);
64int mutt_date_make_imap(char *buf, size_t buflen, time_t timestamp);
65time_t mutt_date_make_time(struct tm *t, bool local);
66int mutt_date_make_tls(char *buf, size_t buflen, time_t timestamp);
67void mutt_date_normalize_time(struct tm *tm);
68time_t mutt_date_parse_date(const char *s, struct Tz *tz_out);
69time_t mutt_date_parse_imap(const char *s);
70void mutt_date_sleep_ms(size_t ms);
71
72#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:956
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
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:942
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:47
unsigned char zminutes
Minutes away from UTC.
Definition: date.h:50
bool zoccident
True if west of UTC, False if East.
Definition: date.h:51
char tzname[8]
Name, e.g. UTC.
Definition: date.h:48
unsigned char zhours
Hours away from UTC.
Definition: date.h:49