Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How convert from float to datetime? #47

Open
Radzhab opened this issue Sep 12, 2017 · 1 comment
Open

How convert from float to datetime? #47

Radzhab opened this issue Sep 12, 2017 · 1 comment

Comments

@Radzhab
Copy link

Radzhab commented Sep 12, 2017

Tod::TimeOfDay.new 7.5 rise error. Invalid value for Integer. How to be in this case?
,

@jackc
Copy link
Owner

jackc commented Sep 14, 2017

I'll assume your 7.5 refers to 7.5 hours. The constructor requires integer components for the time.

What you can do is convert your time to seconds and use .from_second_of_day.

[5] pry(main)> Tod::TimeOfDay.from_second_of_day((7.5 * Tod::TimeOfDay::NUM_SECONDS_IN_HOUR).round)
=> #<Tod::TimeOfDay:0x00000001a085b0 @hour=7, @minute=30, @second=0, @second_of_day=27000>

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

No branches or pull requests

2 participants