Indigo Rose Software

Professional Software Development Tools

 
Results 1 to 9 of 9
  1. #1
    Join Date
    Dec 2005
    Location
    Southern California
    Posts
    73

    Get the users timezone?

    anyone know how I could do this?

    My current project requires that an exported XML document be timestamped in Zulu time, IE -5:00 from EST, -8:00 from PST. So, depending on the users timezone the System.GetTime result would need to be modified.

    I suppose it might be easier to use an http query to an atomic clock or something, maybe a PHP form that gives the current Zulu time.

    But still, could this be done from AMS itself without outside resources?

  2. #2
    Join Date
    Sep 2002
    Location
    Sol 3
    Posts
    3,160
    There is a registry setting for time zone

    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Contro l\TimeZoneInformation

    And a key that contains the offset from UTC in minutes

    Bias or ActiveTimeBias --Hex value of minutes

    you can use tonumber(HEX, 10) to convert a hex number to a decimal number.
    Code:
    Dialog.Message("", tonumber(Registry.GetValue(HKEY_LOCAL_MACHINE, "\\SYSTEM\\CurrentControlSet\\Control\\TimeZoneInformation", "ActiveTimeBias", true),10));
    Quote Originally Posted by MSDN
    Bias
    Specifies the current bias, in minutes, for local time translation on this computer.
    The bias is the difference, in minutes, between UTC and local time.

    All translations between UTC and local time are based on the following formula.

    UTC = local time + bias
    This member is required.
    link

    Tigg
    TJ-Tigger
    "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
    "Draco dormiens nunquam titillandus."
    Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine

  3. #3
    Join Date
    Dec 2005
    Location
    Southern California
    Posts
    73
    awesome. thats purrrrfect haha im lame. seriously, thanks a ton tigg. as always, you rock!

  4. #4
    Corey is offline Indigo Rose Staff Alumni
    Join Date
    Aug 2002
    Posts
    9,746
    Bippity boppity boo.

  5. #5
    Join Date
    Dec 2005
    Location
    Southern California
    Posts
    73
    hmm.. ok.. im having trouble here.

    it works fine for my timezone, and all the ones ive tried that are -'s.. but once i tried the +'s.. things got funkeh. the numbers being output are overly huge. like 4294967236 for +1:00.. now.. thats a helluva lot more than 60 minutes so im confused.. dunno how to do this. im sure im just missing something obvious, and im gonna keep hacking at it. but right now im stumped.

  6. #6
    Join Date
    Sep 2002
    Location
    Sol 3
    Posts
    3,160
    Try taking the number returned and subtract it from 4294967296 to get the number of minutes you add to the current time. You may want to add an if/then to check if it is over 720 then subtract. Like this

    Code:
    nTimeOffset = tonumber(Registry.GetValue(HKEY_LOCAL_MACHINE, "\\SYSTEM\\CurrentControlSet\\Control\\TimeZoneInformation", "ActiveTimeBias", true),10);
    if nTimeOffset > 720 then 
         nAdd = true;
         nTimeOffset = 4294967296 - nTimeOffset;
    else
        nAdd = false;
    end
    
    if nAdd then
         --Positive offset
    else
         --negative offset
    end
    HTH
    Tigg
    TJ-Tigger
    "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
    "Draco dormiens nunquam titillandus."
    Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine

  7. #7
    Join Date
    Dec 2005
    Location
    Southern California
    Posts
    73
    that did the trick. again, thanks a ton tigg.

    question though, where did you get that number? or did you just add 60 to the one i provided? im thinking i mustve missed something in the msdn link, but i dont remember anything about that.

  8. #8
    Join Date
    Sep 2002
    Location
    Sol 3
    Posts
    3,160
    I guessed at it. I figured that the value they were using for positive timezones were represented by using four bytes of data. This is a range of 0x00000000 or a decimal value of 0 (zero) and a max value is then 0xffffffff which has a value of 4294967295. The total number of digits is then 4294967296, so I tried to subtract the decimal value from that to determine the offset and it worked. A little guess work can't explain it but it worked.
    TJ-Tigger
    "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
    "Draco dormiens nunquam titillandus."
    Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine

  9. #9
    Join Date
    Dec 2005
    Location
    Southern California
    Posts
    73
    Well wow, great guess! Thanks to your help ive got it working perfectly for the any time zone, even the ones with minutes involved. Now just to finish it up by having it make sure the date is UTC as well, but that shouldnt be too hard. Just tooo many hours at work today Ill prolly break down and finish at home though, ah well.

Similar Threads

  1. AutoPlay Media Studio 6.0 User's Guide
    By Ted Sullivan in forum AutoPlay Media Studio 6.0
    Replies: 0
    Last Post: 11-03-2005, 01:37 PM
  2. TrueUpdate 2.0 FAQ
    By Colin in forum TrueUpdate 2.0
    Replies: 0
    Last Post: 01-04-2005, 12:25 PM
  3. Setup Factory 7.0 Printed User's Guide
    By Ted Sullivan in forum Setup Factory 7.0
    Replies: 0
    Last Post: 09-22-2004, 12:45 PM
  4. Printed User's Guide & Training CD's
    By Ted Sullivan in forum AutoPlay Media Studio 5.0
    Replies: 0
    Last Post: 11-13-2003, 12:35 PM
  5. Printed User's Guide & Training CD's
    By Ted Sullivan in forum AutoPlay Media Studio 5.0
    Replies: 0
    Last Post: 11-13-2003, 12:35 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts