archlinuxcn / mirrorlist-repo

Arch Linux CN Community repo mirrors list
511 stars 48 forks source link

Use datetime.timedelta instead of custom function #14

Closed Rubo3 closed 3 years ago

Rubo3 commented 3 years ago

I think it would be better to let the standard library do the job of calculating the elapsed time instead of writing a custom function which does the same job. What are your thoughts on this matter?

lilydjwg commented 3 years ago

The format is different. While being language neuter when less than one day, it's less readable. And it's weird to use different format for days and the remaining.

Rubo3 commented 3 years ago

I see, and what about something like this?

time.strftime("%Hh%Mm%Ss", time.gmtime(4*3600+13*60+6)) # '04h13m06s'

I think something could be done with days, too. Let me take a look.

lilydjwg commented 3 years ago

On Tue, Dec 15, 2020 at 12:25:44AM -0800, Marco Rubin wrote:

I see, and what about something like this?

time.strftime("%Hh%Mm%Ss", time.gmtime(4*3600+13*60+6)) # '04h13m06s'

It's a weird way to format intervals. gmtime and strftime are for calendar times.

-- Best regards, lilydjwg

Rubo3 commented 3 years ago

It seems the standard library prefers the hh:mm:ss, not dd:hh:mm:ss. What a pity.