But if you are trying to translate NETWORK time, that is the time from Jan 1, 1900

The code below takes a "brute force" approach, but works. I'm sure some math whiz could
certainly come up with a better formula.



HOffset = Local offset from GMT
Sign = 1 if you are EARLIER than GMT
Sign = 2 if you are LATER than GMT ("+")
DST = 1 if you are using DST

The program takes a "shortcut" in that it calculates time since Jan 1, 2000


Code:
  
               IF sign = "1" then
                  if DST = 1 and HOffset = 0 THEN 
                       Sign = "2"
                       GOTO OtherSide
                  ENDIF     
                    
                     TimeNow = Timenow - ((HOffset - DST) * 3600)
               ENDIF
             
OtherSide:             
               IF Sign = "2" THEN
               
                  TimeNow = TimeNow + ((Hoffset + DST) * 3600)
               ENDIF   
                                     
                SINCEJAN2009 = TIMENOW - 3439756800   ; 3439756800 is the #of sec from Jan1 1900 to Jan1 2009
               
                RUNNINGSECONDS = SINCEjAN2009
                YR = 2009
                
GETYEAR:
        
                    LEAP = (YR//4)    ; = 0 if leap year
                    
                    if LEAP = 0 then
                        SecondsInYear = 31622400 ;366*60*60**24
                     
                    ELSE
                        SecondsInYear = 31536000 ;365*60*60*24
                     
                    endif
                       
                    If RunningSeconds > SecondsInYear Then
                        RunningSeconds = RunningSeconds - SecondsInyear
                        YR = YR + 1
                        GOTO GetYear
                    ENDIF
               
                 Mo = 1 ; Start with Month = 1  
                 
        
GETMONTH:        
                IF LEAP > 0 THEN
                   lookup2 MO,[0,2678400,2419200,2678400,2592000,2678400,2592000,2678400,2678400,2592000,2678400,2592000,2678400],SecondsInMonth
                ELSE
                   LOOKUP2 MO,[0,2678400,2505600,2678400,2592000,2678400,2592000,2678400,2678400,2592000,2678400,2592000,2678400],SecondsInMonth
                ENDIF
                
                If RunningSeconds >= SecondsInMonth THEN
                   RunningSeconds = RunningSeconds - SecondsInMonth
                
                MO = MO + 1
                GOTO GETMONTH
                ENDIF   
FINDDAYS:
        
                DA = RUNNINGSECONDS/86400
                RUNNINGSECONDS = RUNNINGSECONDS//86400
     
                HR = RUNNINGSECONDS/3600 
                RUNNINGSECONDS = RUNNINGSECONDS//3600
       
                MN = RUNNINGSECONDS/60
                RUNNINGSECONDS = RUNNINGSECONDS//60
                SC = RUNNINGSECONDS
            
                Da = Da + 1
               HSEROUT [13,10,13,10,DEC2 HR,":",DEC2 MN,":",DEC2 SC,"   ",DEC2 MO,"/",DEC2 DA,"/",#YR,13,10]