#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    138
    Rep Power
    12

    Angry does the ASP VBscript setLocale function work?


    I am a little confused about what the VBScript setLocale function does in ASP.

    I'm changing the locale from 1033 (US english) to 3081 (Aust English) which should change the date format from mm/dd/yyyy to dd/mm/yyyy

    Session.LCID changes what is returned from getLocale as does setLocale. But only the session.LCID actually change what the date output looks like!

    Here is some code:
    Code:
    <html>
    <head>
      <title></title>
    </head>
    <body>
    getLocale(): <%= getLocale() %><br>
    now() <%= now() %><br>
    setLocale(1033): <%= setLocale(1033) %><br>
    getLocale(): <%= getLocale() %><br>
    now() <%= now() %><br>
    setLocale(3081): <%= setLocale(3081) %><br>
    getLocale(): <%= getLocale() %><br>
    now() <%= now() %><br>
    </body>
    </html>
    getLocale(): 3081
    now() 25/02/2003 12:10:02 PM
    setLocale(1033): 3081
    getLocale(): 1033
    now() 25/02/2003 12:10:02 PM
    setLocale(3081): 1033
    getLocale(): 3081
    now() 25/02/2003 12:10:02 PM


    Here is the work around and output that I would expect from the above!
    Code:
    <html>
    <head>
      <title></title>
    </head>
    <body>
    getLocale(): <%= getLocale() %><br>
    now() <%= now() %><br>
    Session.LCID = 1033: <% Session.LCID = 1033 %><br>
    getLocale(): <%= getLocale() %><br>
    now() <%= now() %><br>
    Session.LCID = 3081: <% Session.LCID = 3081 %><br>
    getLocale(): <%= getLocale() %><br>
    now() <%= now() %><br>
    </body>
    </html>
    getLocale(): 3081
    now() 25/02/2003 12:11:10 PM
    Session.LCID = 1033:
    getLocale(): 1033
    now() 2/25/2003 12:11:10 PM
    Session.LCID = 3081:
    getLocale(): 3081
    now() 25/02/2003 12:11:10 PM

    Can anybody verify my results or explain why this happens?
    I'm using IIS5 on Windows2000. My Os locale is 3081
    --

    ngibsonau
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    138
    Rep Power
    12
    Am I confusing everone?

    Here is my question in English.

    If in ASP using the VBScript function setLocale function and the the getlocale function, the locale returned from the getlocale function is what you set it to with the setlocale function.

    ie.
    Code:
    setlocale(3081)
    response.write getLocale
    will return 3081

    But if your system locale is 1033 (US english) and you do a response.write Now() the date will be returned in the format mm/dd/yyyy. This is not correct not for the locale 3081 (Aust English) which we set it too, it should appear as dd/mm/yyyy

    But if I use Session.LCID = 3081
    and response.write now the date will appear in the format dd/mm/yyyy
    and getLocale will also return 3081, the same return value as for when we called the setlocale function and then getLocale.

    Why doesn't setLocale change the output of the now function and why does it appear to do nothing to the locale except make you think it has changed when it hasn't!

    Is this a Bug in IIS5?
    --

    ngibsonau
  4. #3
  5. superficial
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2002
    Location
    Peterborough, England
    Posts
    188
    Rep Power
    13
    1.) Do you have the default system locale set to what you want, within the web servers regional settings

    2.) Try <%@Language="VBScript" LCID="xxxx"%>

    It's rather crap, as you've found out. I found on an NT web server that I had check the box in the regional settings to make the locale the default in order to make it work how I wanted.......
    _______________
    Matt
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    138
    Rep Power
    12
    yeah I know LCID works.

    where abouts do you set the regional settings for the IIS.

    can you walk me through the dialogs.
    --

    ngibsonau

IMN logo majestic logo threadwatch logo seochat tools logo