forked from neomutt/neomutt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdate.h
76 lines (69 loc) · 2.78 KB
/
date.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/**
* @file
* Time and date handling routines
*
* @authors
* Copyright (C) 2017-2024 Richard Russon <[email protected]>
* Copyright (C) 2019 Victor Fernandes <[email protected]>
* Copyright (C) 2019-2020 Pietro Cerutti <[email protected]>
*
* @copyright
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef MUTT_MUTT_DATE_H
#define MUTT_MUTT_DATE_H
#include <locale.h>
#include <stdbool.h>
#include <stdint.h>
#include <time.h>
#ifdef __APPLE__
#include <xlocale.h>
#endif
struct Buffer;
struct timespec;
/* theoretically time_t can be float but it is integer on most (if not all) systems */
#define TIME_T_MAX ((((time_t) 1 << (sizeof(time_t) * 8 - 2)) - 1) * 2 + 1)
#define TIME_T_MIN (-TIME_T_MAX - 1)
#define TM_YEAR_MAX \
(1970 + (((((TIME_T_MAX - 59) / 60) - 59) / 60) - 23) / 24 / 366)
#define TM_YEAR_MIN (1970 - (TM_YEAR_MAX - 1970) - 1)
/**
* struct Tz - List of recognised Timezones
*/
struct Tz
{
char tzname[8]; ///< Name, e.g. UTC
unsigned char zhours; ///< Hours away from UTC
unsigned char zminutes; ///< Minutes away from UTC
bool zoccident; ///< True if west of UTC, False if East
};
time_t mutt_date_add_timeout(time_t now, time_t timeout);
int mutt_date_check_month(const char *s);
time_t mutt_date_now(void);
uint64_t mutt_date_now_ms(void);
struct tm mutt_date_gmtime(time_t t);
size_t mutt_date_localtime_format(char *buf, size_t buflen, const char *format, time_t t);
size_t mutt_date_localtime_format_locale(char *buf, size_t buflen, const char *format, time_t t, locale_t loc);
struct tm mutt_date_localtime(time_t t);
int mutt_date_local_tz(time_t t);
void mutt_date_make_date(struct Buffer *buf, bool local);
int mutt_date_make_imap(char *buf, size_t buflen, time_t timestamp);
time_t mutt_date_make_time(struct tm *t, bool local);
int mutt_date_make_tls(char *buf, size_t buflen, time_t timestamp);
void mutt_date_normalize_time(struct tm *tm);
time_t mutt_date_parse_date(const char *s, struct Tz *tz_out);
time_t mutt_date_parse_imap(const char *s);
void mutt_date_sleep_ms(size_t ms);
void mutt_time_now(struct timespec *tp);
#endif /* MUTT_MUTT_DATE_H */