+static const char *xt_timestamp_fmt_parse(const char *opt_str, u32 *dest, struct mempool *pool)
+{
+ if(opt_str == NULL) {
+ return "NULL is not supported as a column argument.";
+ }
+
+ if(strcasecmp(opt_str, "timestamp") == 0 || strcasecmp(opt_str, "epoch") == 0) {
+ *dest = TIMESTAMP_EPOCH;
+ return NULL;
+ } else if(strcasecmp(opt_str, "datetime") == 0) {
+ *dest = TIMESTAMP_DATETIME;
+ return NULL;
+ }
+
+ return mp_printf(pool, "Invalid column format option: '%s'.", opt_str);
+}
+
+static const char *xt_timestamp_parse(const char *str, void *dest, struct mempool *pool)
+{
+ errno = 0;
+ char *parse_end = NULL;
+ u64 parsed = strtoul(str, &parse_end, 10);
+ if(str == parse_end) {
+ return mp_printf(pool, "Invalid value of timestamp: '%s'.", str);
+ }
+ if(errno == EINVAL) {
+ return "Error occured during parsing of size.";
+ }
+
+ if(errno == ERANGE) {
+ return "Error: size value either too large or too small.";
+ }
+
+ if(*parse_end == 0) {
+ *(u64*) dest = (u64) parsed;
+ return NULL;
+ }
+
+ struct tm parsed_time;
+ parse_end = strptime(str, "%F %T", &parsed_time);
+ if(parse_end == NULL) {
+ return mp_printf(pool, "Invalid value of timestamp: '%s'.", str);
+ }
+ if(*parse_end != 0) {
+ return mp_printf(pool, "Invalid value of timestamp: '%s'.", str);
+ }
+
+ time_t tmp_time = mktime(&parsed_time);
+ *(u64*)dest = (u64) tmp_time;
+
+ return NULL;
+}
+