From 768b1ef340c27cdfc3bc5c15f8f4c31d15ada122 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Sat, 23 Nov 2013 08:38:04 -0500 Subject: [PATCH 1/1] parse: tz_offset should be returned in seconds --- luatz/parse.lua | 2 +- spec/parse_spec.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/luatz/parse.lua b/luatz/parse.lua index a1a0431..f5cf735 100644 --- a/luatz/parse.lua +++ b/luatz/parse.lua @@ -25,7 +25,7 @@ local function rfc_3339 ( str , init ) else local hour_offset , min_offset = str:match ( "^([+-]%d%d):(%d%d)" , patt_end ) if hour_offset then - tz_offset = tonumber ( hour_offset )*60 + tonumber ( min_offset ) + tz_offset = tonumber ( hour_offset ) * 3600 + tonumber ( min_offset ) * 60 else -- Invalid RFC 3339 timestamp offset (should be Z or (+/-)hour:min -- tz_offset will be nil diff --git a/spec/parse_spec.lua b/spec/parse_spec.lua index f66015a..71df5fb 100644 --- a/spec/parse_spec.lua +++ b/spec/parse_spec.lua @@ -6,7 +6,7 @@ describe ( "Time parsing library" , function ( ) assert.same ( timetable.new(2013,10,22,14,17,02) , (parse.rfc_3339 "2013-10-22T14:17:02Z") ) -- Numeric offsets accepted - assert.same ( { timetable.new(2013,10,22,14,17,02) , 10*60 } , { parse.rfc_3339 "2013-10-22T14:17:02+10:00" } ) + assert.same ( { timetable.new(2013,10,22,14,17,02) , 10*3600 } , { parse.rfc_3339 "2013-10-22T14:17:02+10:00" } ) -- Missing offsets parse assert.same ( timetable.new(2013,10,22,14,17,02) , (parse.rfc_3339 "2013-10-22T14:17:02") ) -- 2.39.5