This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How do I compute a date?

How do I compute the date of the 1st Sunday of April and the last Sunday in October given the year?

I'm working on a project in which a real-time clock has to correct itself for DST automatically.

Any ideas?

Thanks alot
Dana Rodakis

Parents
  • How do you store your RTC in the system? Supposedly you use 32-bit time in seconds, you can have a 10-years or 20-years table which contains DST in/out time for each year. This is the easy way, however, this means your product won't go international.

    Another way I like is to create a virtual monthly calendar table for each "type of month" in your code (i.e., 1st DayOfMonth can start from SUN, MON, ..., SAT, so you'll have 7 types of month). Once you compute the 1st DayOfMonth, you know which table to use and where your first SUN is and where your last SUN is in this month's table.

    Computing RTC is always a tedious job.

Reply
  • How do you store your RTC in the system? Supposedly you use 32-bit time in seconds, you can have a 10-years or 20-years table which contains DST in/out time for each year. This is the easy way, however, this means your product won't go international.

    Another way I like is to create a virtual monthly calendar table for each "type of month" in your code (i.e., 1st DayOfMonth can start from SUN, MON, ..., SAT, so you'll have 7 types of month). Once you compute the 1st DayOfMonth, you know which table to use and where your first SUN is and where your last SUN is in this month's table.

    Computing RTC is always a tedious job.

Children