python - Convert a timedelta to days, hours and minutes -


I have a timetable I want that day, hours and minutes - either as a taple or a dictionary. .. I have no problem.

I have done this once in a dozen languages ​​over a period of time, but Python is usually a simple answer to everything, so I thought I had some nimbi (simple yet verbose) destroyed mathematics Ask here before doing this.

Mr. Fuz raised a good point.

I "Dealing With Listing" (eBay listing like a bit) where each has a duration. I am trying to spend time by doing when_added + duration - now

Is I saying that there will be no account for DST? If not, what is the easiest way to add / subtract an hour?

If you have any Datetime.timedelta value td , td.days already you want "day" to enter TimeDelta value to hold the fraction of the day in seconds (straight hours or Not so) so that you will have to actually "cause the simple math", for example:

  def days_hours_minutes (td): return td Days, td.seconds // 3600, (td.seconds // 60)% 60  

Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -