summaryrefslogtreecommitdiff
path: root/upb/json/parser.rl
diff options
context:
space:
mode:
authorPaul Yang <TeBoring@users.noreply.github.com>2018-09-21 11:07:21 -0700
committerGitHub <noreply@github.com>2018-09-21 11:07:21 -0700
commitb258ae323503d93997b661df1309ff339bd8341d (patch)
treefa6ed780df7066b092c2a8fb10d86a10b831be2f /upb/json/parser.rl
parent706ffdbc658e00fdf0d03715c8306eb7e7b7e963 (diff)
Fix mac use local timezone for strptime by default. (#127)
* Fix mac use local timezone for strptime by default. * Fix comments * Check len == UPB_TIMESTAMP_BASE_SIZE * Fix comment
Diffstat (limited to 'upb/json/parser.rl')
-rw-r--r--upb/json/parser.rl10
1 files changed, 9 insertions, 1 deletions
diff --git a/upb/json/parser.rl b/upb/json/parser.rl
index 217caef..8e6caa9 100644
--- a/upb/json/parser.rl
+++ b/upb/json/parser.rl
@@ -1259,18 +1259,26 @@ static void start_timestamp_base(upb_json_parser *p, const char *ptr) {
capture_begin(p, ptr);
}
+#define UPB_TIMESTAMP_BASE_SIZE 19
+
static bool end_timestamp_base(upb_json_parser *p, const char *ptr) {
size_t len;
const char *buf;
+ /* 3 for GMT and 1 for ending 0 */
+ char timestamp_buf[UPB_TIMESTAMP_BASE_SIZE + 4];
if (!capture_end(p, ptr)) {
return false;
}
buf = accumulate_getptr(p, &len);
+ UPB_ASSERT(len == UPB_TIMESTAMP_BASE_SIZE);
+ memcpy(timestamp_buf, buf, UPB_TIMESTAMP_BASE_SIZE);
+ memcpy(timestamp_buf + UPB_TIMESTAMP_BASE_SIZE, "GMT", 3);
+ timestamp_buf[UPB_TIMESTAMP_BASE_SIZE + 3] = 0;
/* Parse seconds */
- if (strptime(buf, "%FT%H:%M:%S", &p->tm) == NULL) {
+ if (strptime(timestamp_buf, "%FT%H:%M:%S%Z", &p->tm) == NULL) {
upb_status_seterrf(&p->status, "error parsing timestamp: %s", buf);
upb_env_reporterror(p->env, &p->status);
return false;
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback