Change times to Time instances, not Unix timestamps

This commit is contained in:
Sami Samhuri 2025-06-29 14:07:15 -07:00
parent a17773ee35
commit 3fda2e49a0
No known key found for this signature in database
3 changed files with 15 additions and 3 deletions

View file

@ -13,8 +13,8 @@ module Instapaper
attribute? :description, Types::String
attribute? :instapaper_hash, Types::String
attribute? :private_source, Types::String
attribute? :progress_timestamp, Types::Integer.optional
attribute? :time, Types::Integer.optional
attribute? :progress_timestamp, Types::UnixTime
attribute? :time, Types::UnixTime
attribute? :progress, Types::StringOrInteger
attribute? :starred, Types::StringOrInteger
end

View file

@ -11,6 +11,6 @@ module Instapaper
attribute :bookmark_id, Types::Integer
attribute :text, Types::String
attribute :position, Types::Integer
attribute :time, Types::Integer.optional
attribute :time, Types::UnixTime
end
end

View file

@ -18,5 +18,17 @@ module Instapaper
!!value
end
end
# Converts Unix timestamps to Time objects
UnixTime = Types::Time.constructor do |value|
case value
when ::Time
value
when nil
nil
else
::Time.at(value.to_i)
end
end
end
end