unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
blob 50b7c6fef5d87f105fa6905a64922250e41ec8ea 3488 bytes (raw)
name: parse-time-string/parse-time-string.h 	 # note: path name is non-authoritative(*)

 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
 
/*
 * parse time string - user friendly date and time parser
 * Copyright © 2012 Jani Nikula
 *
 * 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/>.
 *
 * Author: Jani Nikula <jani@nikula.org>
 */

#ifndef PARSE_TIME_STRING_H
#define PARSE_TIME_STRING_H

#ifdef __cplusplus
extern "C" {
#endif

#include <time.h>

/* return values for parse_time_string() */
enum {
    PARSE_TIME_OK = 0,
    PARSE_TIME_ERR,		/* unspecified error */
    PARSE_TIME_ERR_LIB,		/* library call failed */
    PARSE_TIME_ERR_ALREADYSET,	/* attempt to set unit twice */
    PARSE_TIME_ERR_FORMAT,	/* generic date/time format error */
    PARSE_TIME_ERR_DATEFORMAT,	/* date format error */
    PARSE_TIME_ERR_TIMEFORMAT,	/* time format error */
    PARSE_TIME_ERR_INVALIDDATE,	/* date value error */
    PARSE_TIME_ERR_INVALIDTIME,	/* time value error */
    PARSE_TIME_ERR_KEYWORD,	/* unknown keyword */
};

/* round values for parse_time_string() */
enum {
    PARSE_TIME_ROUND_DOWN = -1,
    PARSE_TIME_NO_ROUND = 0,
    PARSE_TIME_ROUND_UP = 1,
};

/**
 * parse_time_string() - user friendly date and time parser
 * @s:		string to parse
 * @t:		pointer to time_t to store parsed time in
 * @now:	pointer to time_t containing reference date/time, or NULL
 * @round:	PARSE_TIME_NO_ROUND, PARSE_TIME_ROUND_DOWN, or
 *		PARSE_TIME_ROUND_UP
 *
 * Parse a date/time string 's' and store the parsed date/time result
 * in 't'.
 *
 * A reference date/time is used for determining the "date/time units"
 * (roughly equivalent to struct tm members) not specified by 's'. If
 * 'now' is non-NULL, it must contain a pointer to a time_t to be used
 * as reference date/time. Otherwise, the current time is used.
 *
 * If 's' does not specify a full date/time, the 'round' parameter
 * specifies if and how the result should be rounded as follows:
 *
 *   PARSE_TIME_NO_ROUND: All date/time units that are not specified
 *   by 's' are set to the corresponding unit derived from the
 *   reference date/time.
 *
 *   PARSE_TIME_ROUND_DOWN: All date/time units that are more accurate
 *   than the most accurate unit specified by 's' are set to the
 *   smallest valid value for that unit. Rest of the unspecified units
 *   are set as in PARSE_TIME_NO_ROUND.
 *
 *   PARSE_TIME_ROUND_UP: All date/time units that are more accurate
 *   than the most accurate unit specified by 's' are set to the
 *   smallest valid value for that unit. The most accurate unit
 *   specified by 's' is incremented by one (and this is rolled over
 *   to the less accurate units as necessary). Rest of the unspecified
 *   units are set as in PARSE_TIME_NO_ROUND.
 *
 * Return 0 (PARSE_TIME_OK) for succesfully parsed date/time, or one
 * of PARSE_TIME_ERR_* on error. 't' is not modified on error.
 */
int parse_time_string (const char *s, time_t *t, const time_t *now, int round);

#ifdef __cplusplus
}
#endif

#endif /* PARSE_TIME_STRING_H */

debug log:

solving 50b7c6f ...
found 50b7c6f in https://yhetil.org/notmuch/89741ec9a9687fca8b30aa1a4877392d355dd3ce.1347484177.git.jani@nikula.org/

applying [1/1] https://yhetil.org/notmuch/89741ec9a9687fca8b30aa1a4877392d355dd3ce.1347484177.git.jani@nikula.org/
diff --git a/parse-time-string/parse-time-string.h b/parse-time-string/parse-time-string.h
new file mode 100644
index 0000000..50b7c6f

Checking patch parse-time-string/parse-time-string.h...
Applied patch parse-time-string/parse-time-string.h cleanly.

index at:
100644 50b7c6fef5d87f105fa6905a64922250e41ec8ea	parse-time-string/parse-time-string.h

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).