Skip to content
This repository has been archived by the owner on Apr 17, 2018. It is now read-only.

EpochFloatTime #3

Open
SJD opened this issue Nov 11, 2010 · 1 comment
Open

EpochFloatTime #3

SJD opened this issue Nov 11, 2010 · 1 comment

Comments

@SJD
Copy link

SJD commented Nov 11, 2010

It would be nice to have a more precise EpochTime type. I'm a Ruby newbie, but this seems to work for me;

class EpochFloatTime < Float

        def load(value)
            case value
                when ::Float, ::Integer
                    ::Time.at(value)
                else value
            end
        end

        def dump(value)
            case value
                when ::Float, ::Integer, ::Time then value.to_f
                when ::DateTime then value.to_time.to_f
            end
        end
    end
@tpitale
Copy link
Member

tpitale commented Feb 14, 2016

Could you send a PR, and we can review that. Thanks @SJD!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants