approxidate_careful()

approxidate_careful()#

Parses a human-readable date string and converts it into a timestamp, handling relative and absolute date formats. Returns a timestamp representing the parsed date.

Prototype

timestamp_t approxidate_careful(
    const char *date,
    int *error_ret
);

Parameters

Key

Type

Description

date

const char *

A human-readable date string, supporting absolute dates (e.g., ‘2024-09-17’) and relative dates (e.g., ‘3 days ago’).

error_ret

int *

Pointer to an integer that will be set to a nonzero value if an error occurs during parsing.


Return Value

Returns a timestamp_t representing the parsed date. If parsing fails, the function returns the current time and sets error_ret to a nonzero value.

Notes

This function supports a wide range of date formats, including ISO 8601, RFC 2822, and relative expressions like ‘yesterday’ or ‘next Monday’. It is a more cautious version of approxidate(), ensuring better error handling.

Prototype

// Not applicable in JS

Prototype

# Not applicable in Python
Examples
// TODO C examples
// TODO JS examples
# TODO Python examples