stravalib icon indicating copy to clipboard operation
stravalib copied to clipboard

timedelta vs units.unit('s')

Open b-jazz opened this issue 10 years ago • 1 comments

Shouldn't the elapsed times and moving times be expressed with the units.unit('s') data type instead of as a datetime.timedelta to make calculating things like mph simpler? I'm guessing it is to late to change the library, right? What would be the best way to augment stravalib to support something like this?

b-jazz avatar Dec 27 '14 19:12 b-jazz

Interesting. Yeah, I had probably settled on representing the durations as timedelta instances (since we represent the dates/times as datetime instances) before finalizing on using the units library. Well, we could maybe add an optional parameter (as_timedelta, e.g., default True -- or as_unit or something) to allow for returning units.unit instances instead? Maybe a better idea? We don't have a concept of a central configuration object, which could be useful for this sort of thing.

I will look over the API and see if something smarter jumps out at me. (I guess one question is whether the units framework works natively with timedelta objects already?)

hozn avatar Dec 27 '14 21:12 hozn