On May 11, 4:52 am, [EMAIL PROTECTED] wrote: > On May 9, 5:12 pm, John Machin <[EMAIL PROTECTED]> wrote: > > > > > > > > > On May 10, 7:34 am, [EMAIL PROTECTED] wrote: > > > > Hi, > > > > I am writing a reminder program for our Zimbra email client. One of > > > the requirements I was given was to automatically increment or > > > decrement the display to show something like the following: > > > > 5 minutes until appointment > > > > or > > > > 10 minutes past your appointment > > > > Either way, as each minute goes by, I need to increment it or > > > decrement it. I am having trouble finding a coherent way to take the > > > same date and compare just the number of minutes between them to find > > > the difference. Like if I have an appointment at 9:30 a.m. and the app > > > is loaded at 8 a.m., I need to know the number of minutes or hours and > > > minutes until the appointment. > > > > I have looked at the dateutils module and it has many comparison > > > methods, but they seem to only return the number of days or seconds. > > > Ermmm ... what's wrong with > > > minutes = seconds / 60.0 > > hours = minutes / 60.0 > > > ? > > I'm sure there is a hack for doing something like what you suggest, > but it would be messy. The problem is that I get a datetime object > returned and division really isn't something you can do to one of > those objects. Besides, if I had seconds returned, I would want to > multiply by 60, not divide. > > Maybe I misunderstand you. >
Maybe it's mutual -- hack? messy? multiply? Where I come from, 180 seconds is (180 / 60 = 3) minutes. 180 seconds * 60 is 10800 sixtieths- of-a-second, which appears to be travelling away from a solution to your problem. You have *TWO* datetime objects, (say) appt_dt and now_dt. delta =appt_dt - now_dt # delta is a timedelta object. # calculate difference in minutes mins = delta.days * 24 * 60 + delta.seconds // 60 Have you not read Tim Golden's response? -- http://mail.python.org/mailman/listinfo/python-list