Skip to content

Instantly share code, notes, and snippets.

@odrobnik
Created June 1, 2013 20:55
Show Gist options
  • Save odrobnik/5691712 to your computer and use it in GitHub Desktop.
Save odrobnik/5691712 to your computer and use it in GitHub Desktop.
Quick and very dirty time math
// get a time stamp from a pebble time struct
long timestampFromTime(PblTm time)
{
return (((time.tm_mday * 24) + time.tm_hour) * 60 + time.tm_min) * 60 + time.tm_sec;
}
long timeintervalBetweenTimes(PblTm time1, PblTm time0)
{
long timestamp1 = timestampFromTime(time1);
long timestamp0 = timestampFromTime(time0);
return timestamp0 - timestamp1;
}
@leberwurstsaft
Copy link

Hm, if all you use for calculation is days and less, you'd have to make sure you don't have different months or worse.

I know, this is for WWDC countdown and dirty, but oh well :D

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