[Openroad-users] WindowsAPI call to GetLocalTime

Fabian Anderson fabian.anderson at Fintechnix.com
Wed Apr 23 09:04:12 EST 2008


Hi Bill,

            I like this solution (apart from the fact it integrates via
a batch call) as it gets the required information from the client PC and
applies the time-zone immediately to the Ingres/OpenROAD environment.

 

            I find this line very handy (if it works):-

 

CurSession.TimeZone = ingres_tz

 

            An earlier (probably related) thread asked about changing
the time-zone environment at runtime.  As Ingres environment variables
are only setup when OpenROAD starts, the solution proposed by Bodo was
to call an OpenROAD image for any functions that required a different
environment setting.  If the new time-zone becomes immediately
effective, I think the line above could have been used to solve that
problem too.

 

Regards,

Fabian.

 

 

________________________________

From: openroad-users-bounces at peerlessit.com
[mailto:openroad-users-bounces at peerlessit.com] On Behalf Of Bill Allan
Sent: Tuesday, 22 April 2008 9:52 PM
To: International OpenROAD Users
Subject: Re: [Openroad-users] WindowsAPI call to GetLocalTime

 

Hi Darren and Jade,

 

You say you need to determine which timezone a user's PC is in so you
can get the local time so it can be recorded. A user could be in New
South Wales or in Western Australia (a 2 hr timezone difference).

 

The example below is designed for you to test.  The real eClient
application would only do this once when it starts to get the current
timezone setting on the user's PC and then set the Ingres TimeZone
appropriately.  Just remember that the Windows TimeZone does not exactly
match the Ingres Timezone.  Windows timezone setting only recognizes the
current year and not a history of timezone changes.  As an example on
Windows you set the timezone to '(GMT+10:00) Canberra, Melbourne,
Sydney'. Even though these have the same Daylight savings change dates
this year they have been different in the past.

 

 

Below is a working example to demonstrate what you want to do. 

1.  Create a frame with 4 fields:

    get_tz_btn    Button Field

    tz_result     Varchar(50)

    ingres_tz     Varchar(50)

    cur_time      DATE

 

2.  Add the source code below to the frame script:

 

3.  Run the Frame. Between each click of the get_tz_btn change the
Control Pannel/Date/Timezone value.

 

    The source code creates a bat file with the instructions to get the
'StandardName'for the timezone from Windows into a file.

    Read the result file into a string object.

    Convert the string object to a varchar.

    Extract the StandardName value from the string

    Find the matching Ingres Timezone value.

    Set the CurSession.TimeZone to the derived Ingres Timezone

    assign DATE('now') to a variable.

 

 

Hope this helps.

Bill

 

Here is the source code:

------------------------------------------------------

ON CLICK get_tz_btn =
DECLARE
    l_text    = VARCHAR(2000) NOT NULL,
    l_strobj  = StringObject,
{
    l_text = 'REG QUERY "HKEY_LOCAL_MACHINE\'
            + 'SYSTEM\CurrentControlSet\Control\'
            + 'TimeZoneInformation" /v StandardName'
            + ' > C:\temp\local_tz.txt';
    l_strobj = l_strobj.ConcatVarchar(l_text);
    l_strobj.WriteToFile('C:\temp\local_tz.bat');

 

    CALL SYSTEM 'C:\temp\local_tz.bat';

 

    l_strobj.FileHandle = 'C:\temp\local_tz.txt';
    l_text = l_strobj.value;
    l_text = LEFT(l_text, LENGTH(l_text) -2);
    tz_result = SHIFT(l_text, - (LOCATE(l_text, 'REG_SZ') + 6));

 

    ingres_tz = 'AUSTRALIA-QUEENSLAND';
    CASE tz_result OF
        'AUS Central Standard Time' :     ingres_tz = 'AUSTRALIA-NORTH';
        'AUS Eastern Standard Time' :     ingres_tz = 'AUSTRALIA-NSW';
        'Cen. Australia Standard Time' :  ingres_tz = 'AUSTRALIA-SOUTH';

        'E. Australia' :                  ingres_tz =
'AUSTRALIA-QUEENSLAND'; 
        'E. Australia Standard Time' :    ingres_tz =
'AUSTRALIA-QUEENSLAND'; 
        'Tasmania Standard Time' :        ingres_tz =
'AUSTRALIA-TASMANIA';
        'W. Australia Standard Time' :    ingres_tz =
'AUSTRALIA-WESTERN';
    ENDCASE;

 

    CurSession.TimeZone = ingres_tz;
    cur_time = DATE('now');
}

-------------------------

 

 

 

    

	----- Original Message ----- 

	From: Darren Harvey <mailto:darren.harvey at myworkplace.com.au>  

	To: 'International OpenROAD Users'
<mailto:openroad-users at peerlessit.com>  

	Sent: Tuesday, April 22, 2008 11:44 AM

	Subject: Re: [Openroad-users] WindowsAPI call to GetLocalTime

	 

	Bill

	 

	I'm responding on behalf of Jade.  The problem relates back to
the chain of e-mails titled 'eClient & Timezones'.

	 

	Running an eClient app at sites across multiple Timezones, we
need to be able to get the Current Local time regardless of what
Timezone they are in.  So the App may be hosted in 'AUSTRALIA-NSW' and
the time there may be 11:00.  If a user in Western Australia runs the
application at 9:00 WA time, they see '11:00am', but this is not what we
want.  So what we are trying to achieve is for the eClient app to pick
up the Current local time off the PC.  

	 

	Thanks

	 

	Darren

	 

	 

	Regards

	 

	Darren Harvey

	 

	 

	 

	MyWorkplace Solutions Pty Limited

	Level 5, 11 Queens Road

	Melbourne Victoria 3004

	 

	Ph.       1300 733 731

	Mob.     0400 398 188

	Fax.      03 9710 1112

	 

	Making Service our Priority

	 

	www.MyWorkplace.com.au

	 

	If you receive this email by mistake, please notify us and do
not make any use of the email. We do not waive any privilege,
confidentiality or copyright associated with it.

	 

	
________________________________


	From: openroad-users-bounces at peerlessit.com
[mailto:openroad-users-bounces at peerlessit.com] On Behalf Of Bill Allan
	Sent: Monday, 21 April 2008 7:10 PM
	To: International OpenROAD Users; OpenRoad Users Group
	Subject: Re: [Openroad-users] WindowsAPI call to GetLocalTime

	 

	Can I ask a stupid question?

	 

	Why do you need to use 'GetLocalTime'?   Ingres
DATE_GMT(DATE('now')) will give you a GMT ( UTC) string that can be cut
up and give you all the information apart from the Milliseconds
component.

	 

	In Ingres 2006 there is a new ANSI DATE data type which has a
number of good features.  Here is part of the doco:

	 

	TIME WITH TIME ZONE hh:mm:ss.ffff... [+|-]th:tm 12:45:12.23456
-05:00

	TIME or TIME WITHOUT TIME ZONE hh:mm:ss.ffff... 12:45:12.23456

	other formats are:

	ANSIDATE

	TIME WITH LOCAL TIME ZONE 

	TIMESTAMP WITH TIME ZONE 

	TIMESTAMP or TIMESTAMP WITHOUT TIME ZONE

	TIMESTAMP WITH LOCAL TIME ZONE

	INTERVAL YEAR TO MONTH

	INTERVAL DAY TO SECOND

	Having the Timezone with ANSI DATE just tells you what the
offset from GMT isat that instant. It doesn't tell you the timezone
name.

	Bill Allan.

	----- Original Message ----- 

		From: jade clements
<mailto:jade.clements at myworkplace.com.au>  

		To: OpenRoad Users Group
<mailto:openroad-users at sealion.peerlessit.com>  

		Sent: Monday, April 21, 2008 12:18 PM

		Subject: [Openroad-users] WindowsAPI call to
GetLocalTime

		 

		Hello,

		 

		I'm using a Window's API call, GetLocalTime, to obtain
the user's pc time however I'm getting some weird results.

		 

		procedure zGetTime ( ) =

		declare

		    wYear = INTEGER NOT NULL;

		    wMonth = INTEGER NOT NULL;

		    wDayOfWeek = INTEGER NOT NULL;

		    wDay = INTEGER NOT NULL;

		    wHour = INTEGER NOT NULL;

		    wMinute = INTEGER NOT NULL;

		    wSecond = INTEGER NOT NULL;

		    wMilliseconds = INTEGER NOT NULL;

		 

		enddeclare

		{

		    CALLPROC GetLocalTime(

		        byref(wYear), 

		        byref(wMonth), 

		        byref(wDayOfWeek), 

		        byref(wDay), 

		        byref(wHour), 

		        byref(wMinute), 

		        byref(wSecond), 

		        byref(wMilliseconds));

		 

		CurProcedure.TRACE(

		    'Year: ' + VARCHAR(wYear) + 

		    ' Mth: ' + VARCHAR(wMonth) + 

		    ' Day: ' + VARCHAR(wDay) + 

		    ' Hr: ' + VARCHAR(wHour) + 

		    ' Min: ' + VARCHAR(wMinute) + 

		    ' Sec: ' + VARCHAR(wSecond) + 

		    ' DOW: ' + VARCHAR(wDayOfWeek)); 

		}

		 

		 

		Result:

		Year: 264152 Mth: 1376257 Day: 45023240 Hr: 0 Min: 0
Sec: 0 DOW: 917516

		 

		The Day value changes everytime the procedure is run.

		 

		The API guide mentions that the GetSystemTime function
returns the system time expressed in Coordinated Universal Time (UTC).
I guess the same goes for GetLocalTime however, the return values just
aren't right.

		 

		 

		Can anyone help?

		 

		 

		 

		Regards

		Jade Clements

		 

		

		 

		MyWorkplace Solutions Pty Limited

		Level 5, 11 Queens Road

		Melbourne Victoria 3004

		 

		 

		Ph:  1300 733 731

		Making Service our Priority

		 

		www.MyWorkplace.com.au

		 

		If you receive this email by mistake, please notify us
and do not make any use of the email. We do not waive any privilege,
confidentiality or copyright associated with it.

		 

		 

		
________________________________


	
________________________________________________________________
		OpenROAD-Users mailing list
		
		You can maintain your subscription here:
	
http://www.peerlessit.com/mailman/listinfo/openroad-users
		
		To unsubscribe click on this link
	
mailto:openroad-users-unsubscribe at peerlessit.com&subject=unsubscribe
		
		To subscribe click on this link
	
mailto:openroad-users-subscribe at peerlessit.com&subject=subscribe

	
________________________________


	________________________________________________________________
	OpenROAD-Users mailing list
	
	You can maintain your subscription here:
	http://www.peerlessit.com/mailman/listinfo/openroad-users
	
	To unsubscribe click on this link
	
mailto:openroad-users-unsubscribe at peerlessit.com&subject=unsubscribe
	
	To subscribe click on this link
	mailto:openroad-users-subscribe at peerlessit.com&subject=subscribe


______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________


Specialist providers of back and front office systems for the financial services industry.
Featuring:  Fintechnix(r)
Disclaimer: 
Notice: This message contains privileged and confidential information intended only for the use of the addressee named above. If you are not the intended recipient of this message you are hereby notified that you must not disseminate, copy or take any action in reliance on it.
Any views expressed in this message are those of the individual sender,except where the sender specifically states them to be the views of Fintechnix Pty Ltd.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.peerlessit.com/pipermail/openroad-users/attachments/20080423/ab0070ee/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/jpeg
Size: 1436 bytes
Desc: image001.jpg
Url : http://www.peerlessit.com/pipermail/openroad-users/attachments/20080423/ab0070ee/attachment-0001.jpe 


More information about the Openroad-users mailing list