[futurebasic] Re: [FB] Adjusting time

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : August 1999 : Group Archive : Group : All Groups

From: "Deepesh Letap" <DLetap@...>
Date: Mon, 23 Aug 1999 11:45:01 +0100

Ken,

There is another way which may or may not be suitable for your intended
purpose. Why not use the toolbox time functions? Try the following:

osErr%=FN READDATETIME(Seconds&)
REM Set HoursForward& to +/- time zone hours.
REM 0 is now, +1 is 1 hour forward, -2 is 2 hour backward, etc.
HoursForward&=2
Adjustment&=3600*HoursForward&
Seconds&=Seconds&+Adjustment&
REM Set Format& to 0 for short and 1 for long format.
REM Leading Zeros set from Date & Time control panel.
Format&=0
CALL IUTIMESTRING(Seconds&,Format&,TimeResult$)

PRINT TimeResult$

In your example, you would set HoursForward& based on:

>      CASE _btnClick
>        SELECT id
>          CASE(1)
>            FN radioGroup(1, 1, 5)
>            EDIT$(4) = "-1 hour change"
>            FN adjustTime(1)
             HoursForward&=-1                   <<<<< Added line
>          CASE(2)
>            FN radioGroup(2, 1, 5)
>            EDIT$(4) = "0 hour change"
>            FN adjustTime(2)
             HoursForward&=0                    <<<<< Added line
>          CASE(3)
>            FN radioGroup(3, 1, 5)
>            EDIT$(4) = "1 hour change"
>            FN adjustTime(3)
             HoursForward&=1                    <<<<< Added line
>          CASE(4)
>            FN radioGroup(4, 1, 5)
>            EDIT$(4) = "2 hour change"
>            FN adjustTime(4)
             HoursForward&=2                    <<<<< Added line
>          CASE(5)
>            FN radioGroup(5, 1, 5)
>            EDIT$(4) = "3 hour change"
>            FN adjustTime(5)
             HoursForward&=3                    <<<<< Added line
>          CASE(6)
>            gProgramEnds = true
>        END SELECT


Just some thoughts!

Good luck,

Deep








----------
>From: Ken Shmidheiser <kshmidheiser@...>
>To: futurebasic@...
>Subject: [FB] Adjusting time
>Date: Mon, Aug 23, 1999, 5:36 am
>

> First, compliments to Staz and Co. for the long-awaited release of FB^3!
>
> I'm eagerly looking forward to getting my copy. The subscription
> concept is great, but I do hope that printed manuals-- preferably
> spiral bound-- eventually will be available. (For now it will be a
> couple of reams through the old LaserWriter. It may be the computer
> age, but I still prefer a printed book in front of me.)
>
> I have a question whose answer is probably simplicity itself, but it
> has managed to escape me despite several hours effort. (My last
> question, "How do I delete an invisible file?" was answered by Al
> Staffieri Jr. with one line right from the manual: KILL filename$,
> vRefNum%. Thanks, Al!) I hope this one is as easy.
>
> Here goes:
>
> I'm working on a app where I want the user to be able to see both the
> current time, and the time adjusted for time zone differences. How do
> I add or subtract time from the system time to compensate for the
> time zone differences? I haven't had any success with the manual's
> suggestion (page 310):
>
> currentTime$ = TIME$
>
> and then trying to get a value in the HH:MM:SS format from currentTime$.
>
> I have been able to get a simple hour difference, i.e., if its
> 10:29:13 p.m. Eastern Time, I can return a simple "9" for Central
> Time. But I want the difference to appear in the same HH:MM:SS
> format. (I'm also having some trouble trimming the HH:MM:SS format
> into HH:MM format. Any help there also will be appreciated.) I prefer
> the time to appear in 12 hour rather than 24 hour format.
>
> Following is a quick demo I put together to demonstrate my question.
> (Since I'm in the Eastern Time Zone, I wrote this demo assuming the
> computer system clock is set on Eastern Time, with one time zone,
> Atlantic, an hour ahead, and three zones, Central, Mountain and
> Pacific, one, two and three hours behind, respectively. Even if you
> are not in the Eastern Time Zone, I hope you get the idea. The titles
> of Buttons 1 through 5 are easily changed to reflect your time zones.
> Apologies for the hasty programming.)
>
> My goal is to have the adjusted time zone string appear next to the
> "Adjusted Time:" edit field in the HH:MM:SS format.
>
> All suggestions are welcome.
>
> (Please adjust line length for e-mail line breaks.)
>
> '------------------ Globals -------------------------
> DIM gProgramEnds
> END GLOBALS
>
> '------------------ Functions -----------------------
> LOCAL FN mainWindow
>    WINDOW #1,"Time Adjuster Demo", (6,40)-(295,280), _docNoGrow
>    TEXT _geneva, 12
>
>    MENU 1,0,_enable,"File"
>    MENU 1,1,_enable,"Quit/Q"
>
>    EDIT FIELD #1,"Current System
> Time:",(10,20)-(170,37),_statNoFramed, _rightJust
>    EDIT FIELD #2,"",(175,20)-(275,37),_statFramed, _centerJust
>    EDIT FIELD #3,"Time Adjustment
> Factor:",(10,54)-(170,71),_statNoFramed, _rightJust
>    EDIT FIELD #4,"0",(175,54)-(275,71),_statFramed, _centerJust
>    EDIT FIELD #5,"Adjusted Time:",(10,86)-(170,103),_statNoFramed, _rightJust
>    EDIT FIELD #6,"",(175,86)-(275,103),_statFramed, _centerJust
>
>    EDIT FIELD #7,"Demo written for Eastern Time
> Zone.",(10,210)-(275,225),_statNoFramed, _centerJust
>
>    BUTTON #1, _activeBtn,"Atlantic time",(25,120)-(145,135),_radio
>    BUTTON #2, _markedBtn,"Eastern time",(150,120)-(280,135),_radio
>    BUTTON #3, _activeBtn,"Central time",(25,140)-(145,165),_radio
>    BUTTON #4, _activeBtn,"Mountain time",(150,140)-(280,165),_radio
>    BUTTON #5, _activeBtn,"Pacific time",(25,160)-(145,195),_radio
>
>    BUTTON #6, 1,"Quit",(220,178)-(275,198),_shadow
>
>    WINDOW #1
>
> END FN
>
> LOCAL FN doTimer
>    t$ = TIME$
>
>    LONG IF VAL(t$) >12
>      t$=STR$(VAL(t$)-12) + RIGHT$(t$,6) + " p.m."
>    XELSE
>      t$ = t$ + " a.m."
>    END IF
>
>    EDIT$(2) = t$
>
> END FN
>
> LOCAL FN adjustTime(ID)
>
>    SELECT CASE(ID)
>      CASE(1)
>        adjust = VAL(EDIT$(2)) + 1
>      CASE(2)
>        adjust = VAL(EDIT$(2))
>      CASE(3)
>        adjust = VAL(EDIT$(2)) - 1
>      CASE(4)
>        adjust = VAL(EDIT$(2)) - 2
>      CASE(5)
>        adjust = VAL(EDIT$(2)) - 3
>    END SELECT
>
>    adjust$ = STR$(adjust)
>
>    EDIT$(6) = adjust$
>
> END FN
>
> LOCAL FN radioGroup (btnClicked, first, last)
>    FOR btnNum = first TO last
>      LONG IF BUTTON(btnNum) = _markedBtn
>        BUTTON #btnNum, _activeBtn
>      END IF
>    NEXT btnNum
>    BUTTON # btnClicked, _markedBtn
> END FN
>
> LOCAL FN doDialog
>    evnt = DIALOG(0)
>    id = DIALOG(evnt)
>    SELECT evnt
>      CASE _wndClose
>        WINDOW CLOSE #1
>        gProgramEnds = true
>      CASE _btnClick
>        SELECT id
>          CASE(1)
>            FN radioGroup(1, 1, 5)
>            EDIT$(4) = "-1 hour change"
>            FN adjustTime(1)
>          CASE(2)
>            FN radioGroup(2, 1, 5)
>            EDIT$(4) = "0 hour change"
>            FN adjustTime(2)
>          CASE(3)
>            FN radioGroup(3, 1, 5)
>            EDIT$(4) = "1 hour change"
>            FN adjustTime(3)
>          CASE(4)
>            FN radioGroup(4, 1, 5)
>            EDIT$(4) = "2 hour change"
>            FN adjustTime(4)
>          CASE(5)
>            FN radioGroup(5, 1, 5)
>            EDIT$(4) = "3 hour change"
>            FN adjustTime(5)
>          CASE(6)
>            gProgramEnds = true
>        END SELECT
>    END SELECT
> END FN
>
> LOCAL FN doMenu
>    menuID% = MENU(_menuID)
>    itemID% = MENU(_itemID)
>    IF menuID% = 1 AND itemID% = 1 THEN END
>    MENU
> END FN
>
> '---------------------- Main -------------------------
> WINDOW OFF
> COORDINATE WINDOW
>
> ON DIALOG FN doDialog
> ON MENU FN doMenu
> ON TIMER(1) FN doTimer
>
> FN mainWindow
>
> DO
>    HANDLEEVENTS
> UNTIL gProgramEnds
> ___________________________________________________________________
> Ken Shmidheiser               Systems Administrator/General Manager
>
> Internet: kshmidheiser@...    Fax:  606.679.9225
> Somerset, KY 42502-0221                        Phone:  606.679.4266
> ___________________________________________________________________
>
> --
> To unsubscribe, send ANY message to <futurebasic-unsubscribe@...>
>