Issues with Daylight Zones and How to handle them.

Background of RV Tasks:

In Realvolve app, we had Tasks(Something that needs to be done), Also we had Repeating-Tasks(Something that needs to be to done at regular interval).

Normal Task:    had one occurrence as its a one-time task.
Repeating-Task: had many occurrences, for which we need to track status of occurrence.

Ex:
Repeating-Task: Attending classes for 60 days continuously. Here there are 60 occurrences for which we need to track status like completion(Attended class).

Now, let's dive in Time-zone issue related to daylight.

Don't know DST? follow the link : **What is Daylight-Saving Time? (Daylight Savings)

During DST, clocks are turned forward an hour, effectively moving an hour of daylight from the morning to the evening.

So, DST for 2014 started at March-2nd at 2:00:00 am and ending in November-1st at at 1:59:59 am. The Date may change for every year.

Ex:
Repeating-Task: Attending classes for 60 days continuously starting from Oct-15 at 11am. Here there are 60 occurrences for which we need to track status like completion(Attended class).

In this case, Code Normally adjusts time to 12pm post Nov-2nd. But as a user, he should see the event occurring in the calendar at 11am. So we had to do some adjustments in time while saving to DB, so that it comes up properly irrespective DST.

How we did it?

    def get_offset(set1_occurrence, set2_occurrence)
      set1_occurrence.dst? ? set1_occurrence.period.std_offset : -(set2_occurrence.period.std_offset)
    end

This method will get the offset based on one timezone of the occurrences.