aboutsummaryrefslogtreecommitdiff
path: root/src/parse.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/parse.c')
-rw-r--r--src/parse.c55
1 files changed, 0 insertions, 55 deletions
diff --git a/src/parse.c b/src/parse.c
index 5e2894f0..5190d92c 100644
--- a/src/parse.c
+++ b/src/parse.c
@@ -120,7 +120,6 @@ static PARSER(parse_holding);
static PARSER(parse_if);
static PARSER(parse_inline_c);
static PARSER(parse_int);
-static PARSER(parse_moment);
static PARSER(parse_lambda);
static PARSER(parse_lang_def);
static PARSER(parse_mutexed);
@@ -498,59 +497,6 @@ PARSER(parse_int) {
return NewAST(ctx->file, start, pos, Int, .str=str);
}
-PARSER(parse_moment) {
- const char *start = pos;
- bool negative = match(&pos, "-");
- if (!isdigit(*pos)) return NULL;
-
- struct tm info = {.tm_isdst=-1};
- char *after = strptime(pos, "%Y-%m-%d", &info);
- if (!after) return NULL;
- if (negative) info.tm_year = -(info.tm_year + 1900) - 1900;
- pos = after;
- if (match(&pos, "T") || spaces(&pos) >= 1) {
- after = strptime(pos, "%H:%M", &info);
- if (after) {
- pos = after;
- after = strptime(pos, ":%S", &info);
- if (after) pos = after;
- // TODO parse nanoseconds
- }
- }
-
- const char *before_spaces = pos;
- spaces(&pos);
- 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 moment timezone");
- const char *old_tz = getenv("TZ");
- setenv("TZ", tz, 1);
- tzset();
- moment = (Moment_t){.tv_sec=mktime(&info)};
- if (old_tz) setenv("TZ", old_tz, 1);
- else unsetenv("TZ");
- } else if (*pos == 'Z' || *pos == '-' || *pos == '+') {
- after = strptime(pos, "%z", &info);
- if (after) {
- pos = after;
- long offset = info.tm_gmtoff; // Need to cache this because mktime() mutates it to local timezone >:(
- time_t t = mktime(&info);
- moment = (Moment_t){.tv_sec=t + offset - info.tm_gmtoff};
- } else {
- moment = (Moment_t){.tv_sec=mktime(&info)};
- }
- } else {
- pos = before_spaces;
- moment = (Moment_t){.tv_sec=mktime(&info)};
- }
-
- return NewAST(ctx->file, start, pos, Moment, .moment=moment);
-}
-
type_ast_t *parse_table_type(parse_ctx_t *ctx, const char *pos) {
const char *start = pos;
if (!match(&pos, "{")) return NULL;
@@ -1590,7 +1536,6 @@ PARSER(parse_term_no_suffix) {
ast_t *term = NULL;
(void)(
false
- || (term=parse_moment(ctx, pos)) // Must come before num/int
|| (term=parse_none(ctx, pos))
|| (term=parse_num(ctx, pos)) // Must come before int
|| (term=parse_int(ctx, pos))