mirror of
https://github.com/samsonjs/instapaper.git
synced 2026-03-25 08:55:49 +00:00
Change times to Time instances, not Unix timestamps
This commit is contained in:
parent
a17773ee35
commit
3fda2e49a0
3 changed files with 15 additions and 3 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue