mirror of
https://github.com/valitydev/woody_erlang.git
synced 2024-11-06 02:15:19 +00:00
MSPF-532: fix check for UTC in RFC 3339 date and time (#132)
This commit is contained in:
parent
3ddd842a33
commit
8b8c0e2779
@ -91,9 +91,15 @@ from_unixtime_ms(DeadlineMillisec) ->
|
||||
-spec assert_is_utc(binary()) ->
|
||||
ok | no_return().
|
||||
assert_is_utc(Bin) ->
|
||||
Size = erlang:byte_size(Bin) - 1,
|
||||
Size0 = erlang:byte_size(Bin),
|
||||
Size1 = Size0 - 1,
|
||||
Size6 = Size0 - 6,
|
||||
case Bin of
|
||||
<<_:Size/bytes, "Z">> ->
|
||||
<<_:Size1/bytes, "Z">> ->
|
||||
ok;
|
||||
<<_:Size6/bytes, "+00:00">> ->
|
||||
ok;
|
||||
<<_:Size6/bytes, "-00:00">> ->
|
||||
ok;
|
||||
_ ->
|
||||
erlang:error({bad_deadline, not_utc}, [Bin])
|
||||
|
@ -621,6 +621,8 @@ deadline_to_from_binary_test(_) ->
|
||||
error:{bad_deadline, not_utc} ->
|
||||
ok
|
||||
end,
|
||||
_ = woody_deadline:from_binary(<<"2010-04-11T22:35:41+00:00">>),
|
||||
_ = woody_deadline:from_binary(<<"2010-04-11T22:35:41-00:00">>),
|
||||
|
||||
try woody_deadline:to_binary({{baddate, {22, 35, 41}}, 29})
|
||||
catch
|
||||
|
Loading…
Reference in New Issue
Block a user