Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Creating time object of a non local timezone

Creating time object of a non local timezone

Scheduled Pinned Locked Moved C / C++ / MFC
helpworkspace
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    DimpleSurana
    wrote on last edited by
    #1

    "SystemTimeToTzSpecificLocalTime" Windows Platform SDK call seems to satisy what i want to do. But again to populate the _TIME_ZONE_INFORMATION struct is a problem. Generally it is populated from the local TimeZone (Environment variable). Any Hints/Help to populate this struct with a non-local Timezone data. BOOL SystemTimeToTzSpecificLocalTime( LPTIME_ZONE_INFORMATION lpTimeZone, LPSYSTEMTIME lpUniversalTime, LPSYSTEMTIME lpLocalTime ); typedef struct _TIME_ZONE_INFORMATION { LONG Bias; WCHAR StandardName[32]; SYSTEMTIME StandardDate; LONG StandardBias; WCHAR DaylightName[32]; SYSTEMTIME DaylightDate; LONG DaylightBias; } TIME_ZONE_INFORMATION, *PTIME_ZONE_INFORMATION; Also i was wondering if anybody has seen the MultiTimeZone Clock Screen Saver. If the source code of that could be got it would make life simpler. Dimple

    D 1 Reply Last reply
    0
    • D DimpleSurana

      "SystemTimeToTzSpecificLocalTime" Windows Platform SDK call seems to satisy what i want to do. But again to populate the _TIME_ZONE_INFORMATION struct is a problem. Generally it is populated from the local TimeZone (Environment variable). Any Hints/Help to populate this struct with a non-local Timezone data. BOOL SystemTimeToTzSpecificLocalTime( LPTIME_ZONE_INFORMATION lpTimeZone, LPSYSTEMTIME lpUniversalTime, LPSYSTEMTIME lpLocalTime ); typedef struct _TIME_ZONE_INFORMATION { LONG Bias; WCHAR StandardName[32]; SYSTEMTIME StandardDate; LONG StandardBias; WCHAR DaylightName[32]; SYSTEMTIME DaylightDate; LONG DaylightBias; } TIME_ZONE_INFORMATION, *PTIME_ZONE_INFORMATION; Also i was wondering if anybody has seen the MultiTimeZone Clock Screen Saver. If the source code of that could be got it would make life simpler. Dimple

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      DimpleSurana wrote: Any Hints/Help to populate this struct with a non-local Timezone data. I live in GMT-0600, which is known as CST here in the U.S. If I wanted the time for EST, or GMT-0500, I would do something like:

      TIME_ZONE_INFORMATION tzi = {0};
      SYSTEMTIME stUniversal = {0},
      stLocal = {0};

      tzi.Bias = 300;
      GetSystemTime(&stUniversal); // 16:06 GMT
      SystemTimeToTzSpecificLocalTime(&tzi, &stUniversal, &stLocal); // 11:06 EST


      "The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)

      D 1 Reply Last reply
      0
      • D David Crow

        DimpleSurana wrote: Any Hints/Help to populate this struct with a non-local Timezone data. I live in GMT-0600, which is known as CST here in the U.S. If I wanted the time for EST, or GMT-0500, I would do something like:

        TIME_ZONE_INFORMATION tzi = {0};
        SYSTEMTIME stUniversal = {0},
        stLocal = {0};

        tzi.Bias = 300;
        GetSystemTime(&stUniversal); // 16:06 GMT
        SystemTimeToTzSpecificLocalTime(&tzi, &stUniversal, &stLocal); // 11:06 EST


        "The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)

        D Offline
        D Offline
        DimpleSurana
        wrote on last edited by
        #3

        Hi David, I really appreciate the code snippets you give me. But i wanted to know that how do i add DST information to it too. For eg. EST timezone see's DST. I idea is that "stLocal" will be given its TimeZone only once & hence forth onwards it should always know its TimeZone's Time including DST. Thanks, Dimple

        D 1 Reply Last reply
        0
        • D DimpleSurana

          Hi David, I really appreciate the code snippets you give me. But i wanted to know that how do i add DST information to it too. For eg. EST timezone see's DST. I idea is that "stLocal" will be given its TimeZone only once & hence forth onwards it should always know its TimeZone's Time including DST. Thanks, Dimple

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          Check out the DaylightBias member of the TIME_ZONE_INFORMATION structure.


          "The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)

          D 1 Reply Last reply
          0
          • D David Crow

            Check out the DaylightBias member of the TIME_ZONE_INFORMATION structure.


            "The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)

            D Offline
            D Offline
            DimpleSurana
            wrote on last edited by
            #5

            Do u have ne generic solution that will update the time object based on the incoming timezone. This is gonna require some manual programming i believe so was loking otu for a code snippet. Dimple

            D 1 Reply Last reply
            0
            • D DimpleSurana

              Do u have ne generic solution that will update the time object based on the incoming timezone. This is gonna require some manual programming i believe so was loking otu for a code snippet. Dimple

              D Offline
              D Offline
              David Crow
              wrote on last edited by
              #6

              Nothing that revolves around a "timezone identifier." Otherwise, the DaylightBias and Bias members should solve your problem.


              "The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups