Task

Given the date string "March 7 2009 7:30pm EST", 

output the time 12 hours later in any human-readable format.

As extra credit, display the resulting time in a time zone different from your own.




      INSTALL @lib$+"DATELIB"
 
      date$ = "March 7 2009 7:30pm EST"
 
      mjd% = FN_readdate(date$, "mdy", 0)
      colon% = INSTR(date$, ":")
      hours% = VAL(MID$(date$, colon%-2))
      IF INSTR(date$, "am") IF hours%=12  hours% -= 12
      IF INSTR(date$, "pm") IF hours%<>12 hours% += 12
      mins% = VAL(MID$(date$, colon%+1))
 
      now% = mjd% * 1440 + hours% * 60 + mins%
      new% = now% + 12 * 60 : REM 12 hours later
 
      PRINT FNformat(new%, "EST")
      PRINT FNformat(new% + 5 * 60, "GMT")
      PRINT FNformat(new% - 3 * 60, "PST")
      END
 
      DEF FNformat(datetime%, zone$)
      LOCAL mjd%, hours%, mins%, ampm$
      mjd% = datetime% DIV 1440
      hours% = (datetime% DIV 60) MOD 24
      mins% = datetime% MOD 60
 
      IF hours% < 12 THEN ampm$ = "am" ELSE ampm$ = "pm"
      IF hours% = 0 hours% += 12
      IF hours% > 12 hours% -= 12
 
      = FN_date$(mjd%, "MMMM d yyyy") + " " + STR$(hours%) + \
      \ ":" + RIGHT$("0"+STR$(mins%), 2) + ampm$ + " " + zone$
      ENDPROC
 