From 4231789b71bb42c4ab04e125f98fe5eb3cf030b6 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sun, 17 Nov 2024 14:49:03 -0500 Subject: Rename datetime -> moment --- parse.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'parse.c') diff --git a/parse.c b/parse.c index 1272fe64..5932fba0 100644 --- a/parse.c +++ b/parse.c @@ -110,7 +110,7 @@ static PARSER(parse_heap_alloc); static PARSER(parse_if); static PARSER(parse_inline_c); static PARSER(parse_int); -static PARSER(parse_datetime); +static PARSER(parse_moment); static PARSER(parse_lambda); static PARSER(parse_lang_def); static PARSER(parse_namespace); @@ -508,7 +508,7 @@ PARSER(parse_int) { return NewAST(ctx->file, start, pos, Int, .str=str); } -PARSER(parse_datetime) { +PARSER(parse_moment) { const char *start = pos; bool negative = match(&pos, "-"); if (!isdigit(*pos)) return NULL; @@ -530,17 +530,17 @@ PARSER(parse_datetime) { const char *before_spaces = pos; spaces(&pos); - DateTime_t dt; + Moment_t moment; if (match(&pos, "[")) { size_t tz_len = strcspn(pos, "\r\n]"); const char *tz = heap_strf("%.*s", tz_len, pos); // TODO: check that tz is a valid timezone pos += tz_len; - expect_closing(ctx, &pos, "]", "I wasn't able to parse the rest of this datetime timezone"); + expect_closing(ctx, &pos, "]", "I wasn't able to parse the rest of this moment timezone"); const char *old_tz = getenv("TZ"); setenv("TZ", tz, 1); tzset(); - dt = (DateTime_t){.tv_sec=mktime(&info)}; + moment = (Moment_t){.tv_sec=mktime(&info)}; if (old_tz) setenv("TZ", old_tz, 1); else unsetenv("TZ"); } else if (*pos == 'Z' || *pos == '-' || *pos == '+') { @@ -549,16 +549,16 @@ PARSER(parse_datetime) { pos = after; long offset = info.tm_gmtoff; // Need to cache this because mktime() mutates it to local timezone >:( time_t t = mktime(&info); - dt = (DateTime_t){.tv_sec=t + offset - info.tm_gmtoff}; + moment = (Moment_t){.tv_sec=t + offset - info.tm_gmtoff}; } else { - dt = (DateTime_t){.tv_sec=mktime(&info)}; + moment = (Moment_t){.tv_sec=mktime(&info)}; } } else { pos = before_spaces; - dt = (DateTime_t){.tv_sec=mktime(&info)}; + moment = (Moment_t){.tv_sec=mktime(&info)}; } - return NewAST(ctx->file, start, pos, DateTime, .dt=dt); + return NewAST(ctx->file, start, pos, Moment, .moment=moment); } type_ast_t *parse_table_type(parse_ctx_t *ctx, const char *pos) { @@ -1553,7 +1553,7 @@ PARSER(parse_term_no_suffix) { ast_t *term = NULL; (void)( false - || (term=parse_datetime(ctx, pos)) // Must come before num/int + || (term=parse_moment(ctx, pos)) // Must come before num/int || (term=parse_null(ctx, pos)) || (term=parse_num(ctx, pos)) // Must come before int || (term=parse_int(ctx, pos)) -- cgit v1.2.3