Skip to content

Commit 0858467

Browse files
author
Ryan Bigg
committed
Ensure NDT with ms precision are formatted correctly
1 parent 8e08477 commit 0858467

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

lib/aws_auth/utils.ex

+2
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ defmodule AWSAuth.Utils do
5353
def format_time(time) do
5454
formatted_time = time
5555
|> NaiveDateTime.to_iso8601
56+
|> String.split(".")
57+
|> List.first
5658
|> String.replace("-", "")
5759
|> String.replace(":", "")
5860
formatted_time <> "Z"

test/aws_utils_test.exs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
defmodule AWSAuth.UtilsTest do
2+
use ExUnit.Case
3+
4+
test "format_time formats a time correctly" do
5+
time = AWSAuth.Utils.format_time(~N[2016-10-20 10:32:45.12345])
6+
assert time == "20161020T103245Z"
7+
end
8+
end

0 commit comments

Comments
 (0)