AnsweredAssumed Answered

Converting UNIX times with Daylight Savings Times

Question asked by GeoffreyMartin on Mar 22, 2013
Latest reply on Mar 23, 2013 by GeoffreyMartin

Title

Converting UNIX times with Daylight Savings Times

Post

     I recently discovered that I had a problem with my conversion of my unix date_time to FM timestamps, that didn't account for DST.  I found an article on the knowlegebase but it was outdated, the DST dates have changed. I've updated that formula:

      

     If (LCATS::date < (Date(3 ; 7  ; Year(LCATS::date)) + 
     Middle("0654321" ; DayOfWeek(Date(3 ; 7 ; Year(LCATS::date))) ; 1)) 
     or LCATS::date >= (Date(11 ; 1 ; Year(LCATS::date)) + Middle("0654321" ; DayOfWeek(Date(11 ; 1 ; Year(LCATS::date))); 1)) ; -8 ; -7)
      
     The -8 and -7 are for my timezone, to use change those numbers to your local timezone.  
      
     I use the above calculation for the offset parameter for the custom formula at the bottom to convert the unix times.  There's only one thing that isn't taken into account here...the timechange happens at 0200.  I have another field that returns hour of day (calc_hod), I tried using the above like this: 
      
               If ((calc_hod  ≥ 2 and LCATS::date < 
               (Date(3 ; 7  ; Year(LCATS::date)) + 
               Middle("0654321" ; DayOfWeek(Date(3 ; 7 ; Year(LCATS::date))) ; 1))) 
               or (calc_hod  ≥  2 and LCATS::date >= (Date(11 ; 1 ; Year(LCATS::date)) + Middle("0654321" ; DayOfWeek(Date(11 ; 1 ; Year(LCATS::date))); 1))) ; -8 ; -7)
                
               But now, it's changing every day.  Order of operations??  My brain is mush.  Any help?
                
     I used the time.convert formula (a brilliant formula) created by Rob Poelking at http://www.briandunning.com/cf/1161 to do the unix conversions.
      
     Thanks in advance.
      
      

Outcomes