Sunday 7 July 2013

Time and Programing issues with it

Time and Issues with it.
I have worked with RTC (and arduino for a real life project )and some programming problems related to time.
I want to keep it noted so next time dont fall in this trouble.
This problems are mostly while comparing two time instances.

> Time I generally denote as hh:mm:ss ,also consider it 24 hours scale.
24th hour is 00:00:00.

> An hour starts as 01:00:00 and end at 01:59:59 thus an Interval is measured this way. Adding time such as adding 2:15 hours to time 1:47 as

new min=(15+47)%60 where % is module and floor of ((15+45)/60) is added to hour as 2+1+floor((15+45)/60).

> subtracting time such as 3:12 minus 2:31 is like
  subtract minutes as
if (12 <31),
 hour -1(i.e 3 - 1)
 and  than min + 60, (i.e 12+60)
and then subtracting minutes as 72-31=41 min and then subtracting hours as 2 - 2 = 0.
that gives 00:41 answer for the subtraction
I will still put others, I know more issues but I don't remembered most of those I dugout my previous code and put those too here soon.

 I was motivated by  Question on time intervals on Amazon Interview street challenge https://amazon.interviewstreet.com/challenges/dashboard/#problem/4fd651016cd04
 

No comments:

Post a Comment