Author Topic: Daylight Savings time, Leap Year  (Read 8979 times)

Richard Baum

  • Guest
Daylight Savings time, Leap Year
« on: June 13, 2004, 08:05:37 AM »
How does the RTC handle Daylight Savings Time and Leap Years?

My application requires me to note a date and time and add 12 days and 4 hours to it and wait for that date and time.  If I do this at towards the end of February or around the time changes, how will it react?

Is there a way for me to get the day of the year out of the PLC without multiplying by number of days in each month and adding?  It would be helpful if DATE[5] was the day of the year.  I know you can't customize the PLC for everyone though.


support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3171
    • View Profile
    • Internet Programmable PLCs
Re:Daylight Savings time, Leap Year
« Reply #1 on: June 14, 2004, 06:14:44 PM »
The RTC handles Leap year but does not handle the Daylight Savings.  

DATE[1] is the year, DATE[2] is the month and DATE[3] is the day. DATE[4] is the day of the week.

Leap year is the year that is divisible by 4. So year 2004 is a leap year but not 2005, 2006 and 2007. That should give you a clue on how to handle the leap year.

12 days and 4 hours = 292 hours = 17520 minutes. You may want to construct a timer that will increment a counter every minutes and when it counted down from 17520 to zero it can trigger your event - I think it will execute a lot faster and the code is cleaner too.
Email: support@triplc.com
Tel: 1-877-TRI-PLCS