Skip to content

Commit 15352e8

Browse files
committed
add precision option for datetime string dumping
1 parent c64dbae commit 15352e8

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/dynamoid/dumping.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,11 @@ def format_datetime(value, options)
222222

223223
if use_string_format
224224
value_in_time_zone = Dynamoid::DynamodbTimeZone.in_time_zone(value)
225-
value_in_time_zone.iso8601
225+
if options[:iso_precision].nil?
226+
value_in_time_zone.iso8601
227+
else
228+
value_in_time_zone.iso8601(options[:iso_precision].to_i)
229+
end
226230
else
227231
unless value.respond_to?(:to_i) && value.respond_to?(:nsec)
228232
value = value.to_time

0 commit comments

Comments
 (0)