|
 |
asp_components thread: ASP & VB COM Regional Date/Time Formats...Win2k bug?
Message #1 by "Chester Kuei (EUS)" <Chester.Kuei@a...> on Mon, 26 Nov 2001 14:15:12 -0600
|
|
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
------_=_NextPart_001_01C176B7.0DEE0540
Content-Type: text/plain;
charset="iso-8859-1"
Hi,
There's this weird thing I cannot figure out how to overcome. It has to do with the different regional date/time formats. In
summary, under Win2K, when my ASP calls a VB COM object, the VB COM object formats the date/time in English format no matter what
regional settings I set (SYSTEM and/or user). My system OS is Win2k Server sp2. Here's the code:
------------
' (This is the VB COM object. Suppose the ProgID for this object is "TestDate.Date")
function FormatDT(inDate, inFormat)
FormatDT = FormatDateTime(inDate, inFormat)
end function
------------
In my ASP:
------------
dim oTest, strDate
Set oTest = Server.CreateObject("TestDate.Date")
strDate = "4/1/2001" ' English Date: April 1st, 2001
response.write "Scripting Engine FormatDateTime(): " & FormatDateTime(strDate, vbLongDate)
response.write "Object FormatDateTime(): " & oTest.FormatDT(strDate, vbLongDate)
-------------
Under NT 4.0:
- I set the SYSTEM DEFAULT LOCALE to English and the currently logged in user's regional setting to English. The results are that
both calls return the date formatted in English format.
- I change the current logged in user's regional setting to German and the scripting engine call stays English, but the object call
changes to German.
So NT4.0 works fine.
Now, the problem is, under Win2K, it works differently:
- Even if I set both the SYSTEM DEFAULT LOCALE and the currently logged in user's locale to German, the object call ALWAYS returns
in English format. The scripting engine call follows the system default locale settings however.
How do I get the object call to always be in the same locale as the scripting engine is? I cannot hardcode it because this web
application could be installed on a machine with any locale settings. It seems to always return English formatted dates.
Thanks!
Message #2 by "Joe Hughes" <JoeHughes@M...> on Mon, 26 Nov 2001 22:13:27 -0000
|
|
Hi Chester,
I suspect you may be able to use Session.LCID - I think once the values are
returned to ASP, it will write it out in English regardless, unless you set
the Session.LCID.
If you set the LCID at the top of your ASP page you can then format the
dates depending on the LCID set.
e.g
<%
Session.LCID = 2057 '(UK English)
Session.LCID = 1033 '(US English)
Session.LCID = 1031 '(** German **)
%>
Example of its use;
http://www.4guysfromrolla.com/webtech/041001-1.shtml
For a valid list of LCID's;
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/spsdk11/RPC
_Parameters/lcid.asp
Hope this helps,
Joe Hughes
[JoeHughes@M...]
-----------------------------------------------------------------
----- Original Message ----- From: Chester Kuei (EUS)
To: ASP components
Sent: Monday, November 26, 2001 8:15 PM
Subject: [asp_components] ASP & VB COM Regional Date/Time Formats...Win2k
bug?
Hi,
There's this weird thing I cannot figure out how to overcome. It has to do
with the different regional date/time formats. In summary, under Win2K,
when my ASP calls a VB COM object, the VB COM object formats the date/time
in English format no matter what regional settings I set (SYSTEM and/or
user). My system OS is Win2k Server sp2. Here's the code:
------------
' (This is the VB COM object. Suppose the ProgID for this object is
"TestDate.Date")
function FormatDT(inDate, inFormat)
FormatDT = FormatDateTime(inDate, inFormat)
end function
------------
In my ASP:
------------
dim oTest, strDate
Set oTest = Server.CreateObject("TestDate.Date")
strDate = "4/1/2001" ' English Date: April 1st, 2001
response.write "Scripting Engine FormatDateTime(): " &
FormatDateTime(strDate, vbLongDate)
response.write "Object FormatDateTime(): " & oTest.FormatDT(strDate,
vbLongDate)
-------------
Under NT 4.0:
- I set the SYSTEM DEFAULT LOCALE to English and the currently logged in
user's regional setting to English. The results are that both calls return
the date formatted in English format.
- I change the current logged in user's regional setting to German and the
scripting engine call stays English, but the object call changes to German.
So NT4.0 works fine.
Now, the problem is, under Win2K, it works differently:
- Even if I set both the SYSTEM DEFAULT LOCALE and the currently logged in
user's locale to German, the object call ALWAYS returns in English format.
The scripting engine call follows the system default locale settings
however.
How do I get the object call to always be in the same locale as the
scripting engine is? I cannot hardcode it because this web application
could be installed on a machine with any locale settings. It seems to
always return English formatted dates.
Thanks!
$subst('Email.Unsub')
Message #3 by "Chester Kuei (EUS)" <Chester.Kuei@a...> on Mon, 26 Nov 2001 19:03:18 -0600
|
|
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
------_=_NextPart_001_01C176DF.4CFB5990
Content-Type: text/plain;
charset="iso-8859-1"
Hi Joe,
I just tried the Session.LCID and it doesn't work unfortunately. I believe the Session.LCID only affects calls to the scripting
engine.
-----Original Message-----
From: Joe Hughes [mailto:JoeHughes@M...]
Sent: Monday, November 26, 2001 2:13 PM
To: ASP components
Subject: [asp_components] Re: ASP & VB COM Regional Date/Time
Formats...Win2k bug?
Hi Chester,
I suspect you may be able to use Session.LCID - I think once the values are
returned to ASP, it will write it out in English regardless, unless you set
the Session.LCID.
If you set the LCID at the top of your ASP page you can then format the
dates depending on the LCID set.
e.g
<%
Session.LCID = 2057 '(UK English)
Session.LCID = 1033 '(US English)
Session.LCID = 1031 '(** German **)
%>
Example of its use;
http://www.4guysfromrolla.com/webtech/041001-1.shtml
For a valid list of LCID's;
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/spsdk11/RPC
_Parameters/lcid.asp
Hope this helps,
Joe Hughes
[JoeHughes@M...]
-----------------------------------------------------------------
----- Original Message ----- From: Chester Kuei (EUS)
To: ASP components
Sent: Monday, November 26, 2001 8:15 PM
Subject: [asp_components] ASP & VB COM Regional Date/Time Formats...Win2k
bug?
Hi,
There's this weird thing I cannot figure out how to overcome. It has to do
with the different regional date/time formats. In summary, under Win2K,
when my ASP calls a VB COM object, the VB COM object formats the date/time
in English format no matter what regional settings I set (SYSTEM and/or
user). My system OS is Win2k Server sp2. Here's the code:
------------
' (This is the VB COM object. Suppose the ProgID for this object is
"TestDate.Date")
function FormatDT(inDate, inFormat)
FormatDT = FormatDateTime(inDate, inFormat)
end function
------------
In my ASP:
------------
dim oTest, strDate
Set oTest = Server.CreateObject("TestDate.Date")
strDate = "4/1/2001" ' English Date: April 1st, 2001
response.write "Scripting Engine FormatDateTime(): " &
FormatDateTime(strDate, vbLongDate)
response.write "Object FormatDateTime(): " & oTest.FormatDT(strDate,
vbLongDate)
-------------
Under NT 4.0:
- I set the SYSTEM DEFAULT LOCALE to English and the currently logged in
user's regional setting to English. The results are that both calls return
the date formatted in English format.
- I change the current logged in user's regional setting to German and the
scripting engine call stays English, but the object call changes to German.
So NT4.0 works fine.
Now, the problem is, under Win2K, it works differently:
- Even if I set both the SYSTEM DEFAULT LOCALE and the currently logged in
user's locale to German, the object call ALWAYS returns in English format.
The scripting engine call follows the system default locale settings
however.
How do I get the object call to always be in the same locale as the
scripting engine is? I cannot hardcode it because this web application
could be installed on a machine with any locale settings. It seems to
always return English formatted dates.
Thanks!
$subst('Email.Unsub')
|
|
 |