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

Time helper functions inSeconds, inMinutes etc. error #922

Closed
Saulzar opened this Issue Nov 24, 2017 · 6 comments

Comments

Projects
None yet
6 participants
@Saulzar

Saulzar commented Nov 24, 2017

Time is an alias for Float which specifies time as a unit of milliseconds as far as I can tell. However, the helper functions inSeconds

inSeconds : Time -> Float
inSeconds t =  t / second

For exampleisSeconds 2 = 0.002 !! Where 2 seconds should be 2000 milliseconds

Instead of divding by second it should be multiplied.

inSeconds : Time -> Float
inSeconds t =  t * second
@process-bot

This comment has been minimized.

Show comment
Hide comment
@process-bot

process-bot Nov 24, 2017

Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it!

Here is what to expect next, and if anyone wants to comment, keep these things in mind.

process-bot commented Nov 24, 2017

Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it!

Here is what to expect next, and if anyone wants to comment, keep these things in mind.

@zwilias

This comment has been minimized.

Show comment
Hide comment
@zwilias

zwilias Nov 24, 2017

Member

The intended usage, which isn't terribly well documented, is that you can do something like this:

twoMinutes : Time
twoMinutes = 2 * Time.minute

inSeconds twoMinutes --> 120

The multiplication you propose as implementation for the inSeconds function is pretty much what you would use right now to convert a Float into Time.

Perhaps a second set of functions can be added like fromSeconds which turns a number of seconds into an equivalent Time representation, though.

Member

zwilias commented Nov 24, 2017

The intended usage, which isn't terribly well documented, is that you can do something like this:

twoMinutes : Time
twoMinutes = 2 * Time.minute

inSeconds twoMinutes --> 120

The multiplication you propose as implementation for the inSeconds function is pretty much what you would use right now to convert a Float into Time.

Perhaps a second set of functions can be added like fromSeconds which turns a number of seconds into an equivalent Time representation, though.

@Skinney

This comment has been minimized.

Show comment
Hide comment
@Skinney

Skinney Nov 24, 2017

Contributor

I think a lot of this confusion can be cleared up by specifying that Time represents milliseconds, and filling out examples for all the functions in the namespace.

Contributor

Skinney commented Nov 24, 2017

I think a lot of this confusion can be cleared up by specifying that Time represents milliseconds, and filling out examples for all the functions in the namespace.

@Skinney

This comment has been minimized.

Show comment
Hide comment
@Skinney

Skinney Nov 24, 2017

Contributor

But the entire Time api is about to change in 0.19 anyway, right? So maybe this is a moot issue.

Contributor

Skinney commented Nov 24, 2017

But the entire Time api is about to change in 0.19 anyway, right? So maybe this is a moot issue.

@mkwiatkowski

This comment has been minimized.

Show comment
Hide comment
@mkwiatkowski

mkwiatkowski Nov 24, 2017

The API will change, but the documentation problem may remain. Current code on the dev branch is a bit confusing as the new Posix type seems to hold seconds (https://github.com/elm-lang/core/blob/dev/src/Time.elm#L62), but other functions treat it as milliseconds (https://github.com/elm-lang/core/blob/dev/src/Time.elm#L82).

mkwiatkowski commented Nov 24, 2017

The API will change, but the documentation problem may remain. Current code on the dev branch is a bit confusing as the new Posix type seems to hold seconds (https://github.com/elm-lang/core/blob/dev/src/Time.elm#L62), but other functions treat it as milliseconds (https://github.com/elm-lang/core/blob/dev/src/Time.elm#L82).

@evancz

This comment has been minimized.

Show comment
Hide comment
@evancz

evancz Mar 7, 2018

Member

There is a PR about adding docs for these functions (#920) so I'll let that be the canonical one.

The documentation is gonna get updated for the new API. It's not the same, so the docs cannot stay the same.

Member

evancz commented Mar 7, 2018

There is a PR about adding docs for these functions (#920) so I'll let that be the canonical one.

The documentation is gonna get updated for the new API. It's not the same, so the docs cannot stay the same.

@evancz evancz closed this Mar 7, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment