96 tm.tm_mday -= (7 * count);
125 struct tm tm = { 0 };
126 localtime_r(&t, &tm);
168 ASSERT(rd_match &&
"Unknown UID");
170 const long t_test = rd_match->
get_number(node, data, flags);
175 if (priv->
count == 0)
180 return (t_test > t_cutoff);
209 const char **parsed_until,
217 unsigned short number = 0;
221 if (!end_ptr || (number == USHRT_MAX))
224 snprintf(err->
message,
sizeof(err->
message),
_(
"Invalid number: %s"), str);
233 if (!strchr(
"ymwdHM", *str))
238 _(
"Invalid time period: '%c', must be one of 'ymwdHM'"), *str);
243 *parsed_until = str + 1;
const char * mutt_str_atous(const char *str, unsigned short *dst)
Convert ASCII string to an unsigned short.
const struct ExpandoRenderData * find_get_number(const struct ExpandoRenderData *rdata, int did, int uid)
Find a get_number() callback function.
struct ExpandoNode * node_conddate_parse(const char *str, int did, int uid, const char **parsed_until, struct ExpandoParseError *err)
Parse a CondDate format string - Implements ExpandoDefinition::parse() -.
int node_conddate_render(const struct ExpandoNode *node, const struct ExpandoRenderData *rdata, struct Buffer *buf, int max_cols, void *data, MuttFormatFlags flags)
Render a CondDate Node - Implements ExpandoNode::render() -.
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
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 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.
int(* render)(const struct ExpandoNode *node, const struct ExpandoRenderData *rdata, struct Buffer *buf, int max_cols, void *data, MuttFormatFlags flags)
void * ndata
Private node data.
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.
const char * position
Position of error in original string.
char message[256]
Error message.
long(* get_number)(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
Private data for a Conditional Date -.
int count
Number of 'units' to count.
char period
Units, e.g. 'd' Day or 'm' Month.