96 tm.tm_mday -= (7 * count);
125 struct tm tm = { 0 };
126 localtime_r(&t, &tm);
158 bow = tm.tm_wday - 1;
176 ASSERT(erc_match &&
"Unknown UID");
178 const long t_test = erc_match->
get_number(node, data, flags);
183 if (priv->
count == 0)
188 return (t_test > t_cutoff);
222 const char **parsed_until,
225 if (!str || (str[0] ==
'\0') || !parsed_until || !err)
235 unsigned short number = 0;
239 if (!end_ptr || (number == USHRT_MAX))
242 snprintf(err->
message,
sizeof(err->
message),
_(
"Invalid number: %s"), str);
251 if (!strchr(
"ymwdHM", *str))
256 _(
"Invalid time period: '%c', must be one of 'ymwdHM'"), *str);
261 *parsed_until = str + 1;
const char * mutt_str_atous(const char *str, unsigned short *dst)
Convert ASCII string to an unsigned short.
const struct ExpandoRenderCallback * find_get_number(const struct ExpandoRenderCallback *erc, int did, int uid)
Find a get_number() callback function.
int node_conddate_render(const struct ExpandoNode *node, const struct ExpandoRenderCallback *erc, struct Buffer *buf, int max_cols, void *data, MuttFormatFlags flags)
Render a CondDate Node - Implements ExpandoNode::render() -.
#define MUTT_MEM_CALLOC(n, type)
time_t mutt_date_now(void)
Return the number of seconds since the Unix epoch.
Convenience wrapper for the library headers.
struct ExpandoNode * node_new(void)
Create a new empty ExpandoNode.
@ ENT_CONDDATE
True/False date condition.
struct ExpandoNode * node_conddate_new(int count, char period, int did, int uid)
Create a new CondDate ExpandoNode.
struct ExpandoNode * node_conddate_parse(const char *str, int did, int uid, const char **parsed_until, struct ExpandoParseError *err)
Parse a CondDate format string.
struct NodeCondDatePrivate * node_conddate_private_new(int count, char period)
Create new CondDate private data.
time_t cutoff_number(char period, int count)
Calculate the cutoff time for n units.
time_t cutoff_this(char period)
Calculcate the cutoff time of this unit.
void node_conddate_private_free(void **ptr)
Free CondDate private data - Implements ExpandoNode::ndata_free()
Expando Node for a Conditional Date.
Render Expandos using Data.
uint8_t MuttFormatFlags
Flags for expando_render(), e.g. MUTT_FORMAT_FORCESUBJ.
String manipulation buffer.
int uid
Unique ID, e.g. ED_EMA_SIZE.
void * ndata
Private node data.
int(* render)(const struct ExpandoNode *node, const struct ExpandoRenderCallback *erc, struct Buffer *buf, int max_cols, void *data, MuttFormatFlags flags)
int did
Domain ID, e.g. ED_EMAIL.
enum ExpandoNodeType type
Type of Node, e.g. ENT_EXPANDO.
void(* ndata_free)(void **ptr)
Function to free the private node data.
Buffer for parsing errors.
char message[1024]
Error message.
const char * position
Position of error in original string.
Private data for a Conditional Date -.
int count
Number of 'units' to count.
char period
Units, e.g. 'd' Day or 'm' Month.