The application should be able to convert time from Indian timezone to Munich and Boston timezone. This conversion is related to my current project.
With this weird requirement, I decided to use the most weird way to convert time. I decided to use the timeanddate.com timezone converter to do the conversion. As a result, the application has to make an
HTTP GET
call to this link and parse the resulting web page to find the converted time.Summarizing the Approach:
- Write a REBOL UI application that takes the Indian time as input
- On click of
Convert
, makes anHTTP
call to the website with input given by the user. - Parse the resulting web page and find the converted time.
- Show the converted time on the UI !!
Here is the REBOL code for the application.
This is a REBOL code for timezone convertor
REBOL
[
Title: "Timezone Convertor IN to BOS & MUN"
Author: "Srikanth Seshadri"
]
t-time: to-string now/time
time-get: func [inp-time tz] [
page: reform [
"http://www.timeanddate.com/worldclock/converted.html?hour="inp-time/hour"&min="inp-time/minute"&sec="inp-time/second"&p1=438&p2="tz]
tzurl: to-url page
tz-text: load/markup tzurl
zone-found: false tg-time: now
foreach item tz-text [
if all [string? item zone-found ] [ tg-time: item break]
if all [string? item any[ find item "(U.S.A" find item "(Germ"] ] [zone-found: true]
]
tg-time
]
gui: layout [
backdrop effect [gradient 0x1 white]
across
h3 "Timezone Converter IN -> BOS & MUN" black return
lab "Indian Time"
t-time: field t-time 60x24 return
tab
button "Convert Time" [
inp-time: (to-time t-time/text)
if inp-time
[
boslbl/text: reform ["Time in Boston: " time-get inp-time 43]
munlbl/text: reform ["Time in Munich: " time-get inp-time 83]
show boslbl
show munlbl
]
] keycode [#"^m"] return
boslbl: h4 "[---------------------------------------------------------------------]" return
munlbl: h4 "[---------------------------------------------------------------------]" return
]
view center-face gui
and the output
This is most strange way to do timezone conversion, but the learnings and development was fun; all the effort was worth it!