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. Adding timezone to a COleDateTime object

Adding timezone to a COleDateTime object

Scheduled Pinned Locked Moved C / C++ / MFC
announcement
18 Posts 4 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.
  • R rw104

    Hmmm... No idea but..... look at java functions maybe its worth passing some other data like.... the TimeZone has an operation as follows getOffset( int era, int year, int month, int day, int dayOfWeek, int milliseconds ) era = the era of the given date. year = the year in the given date. month = the month in the given date. Month is 0-based. e.g., 0 for January. day= the day-in-month of the given date. dayOfWeek = the day-of-week of the given date. )= Monday etc milliseconds = the millis in day. Returns the offset to add *to* GMT to get local time, as an int You could use this, couldn't you????

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

    Exactly i was thinking on similar lines cos i do not find ne thing on the C++ side to associate with that Timezone id directly. I will calculate the offset on the java side it self & give it to VC to add/subtract to the COleDateTime object

    R 1 Reply Last reply
    0
    • D DimpleSurana

      I have a COleDateTime object initialised in the following way. COleDateTime m_ReadPointer = COleDateTime::GetCurrentTime(); I need to know a way to update the object to reflect the correct datetime given the TimeZone id. For eg. 1259 A Code snippet will be helpful Dimple

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

      Look at the Bias member of 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

        Look at the Bias member of 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
        #11

        but how will that help me. I have done study of all the structures of c++.

        D 1 Reply Last reply
        0
        • D DimpleSurana

          but how will that help me. I have done study of all the structures of c++.

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

          DimpleSurana wrote: but how will that help me. See here. DimpleSurana wrote: I have done study of all the structures of c++. Apparently not, or you would know that that structure is used by GetTimeZoneInformation().


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

          D 1 Reply Last reply
          0
          • D David Crow

            DimpleSurana wrote: but how will that help me. See here. DimpleSurana wrote: I have done study of all the structures of c++. Apparently not, or you would know that that structure is used by GetTimeZoneInformation().


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

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

            yup i do know that too but the data i have in hand is a TimeZone id which is java specific. How do i use that value to update my COleDateTime object:suss:

            D 1 Reply Last reply
            0
            • D DimpleSurana

              Exactly i was thinking on similar lines cos i do not find ne thing on the C++ side to associate with that Timezone id directly. I will calculate the offset on the java side it self & give it to VC to add/subtract to the COleDateTime object

              R Offline
              R Offline
              rw104
              wrote on last edited by
              #14

              Cool , goodluck with it, that TimeZone ID was bizarre

              1 Reply Last reply
              0
              • D DimpleSurana

                yup i do know that too but the data i have in hand is a TimeZone id which is java specific. How do i use that value to update my COleDateTime object:suss:

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

                DimpleSurana wrote: How do i use that value to update my COleDateTime object You don't (or maybe the id you have from Java's TimeZone class is a requirement, in which case I'm not sure of a solution). The Bias member of the TIME_ZONE_INFORMATION structure tells you how far from UTC you are and in what direction. Here is one solution:

                TIME_ZONE_INFORMATION tza;
                COleDateTime today = COleDateTime::GetCurrentTime();
                GetTimeZoneInformation(&tza);
                cout << "The local time is " << (LPCTSTR) today.Format("%H:%M:%S") << endl;
                today.m_dt = today.m_dt + (tza.Bias / 1440.0);
                cout << "UTC time is " << (LPCTSTR) today.Format("%H:%M:%S") << endl;


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

                1 Reply Last reply
                0
                • D DimpleSurana

                  Ok its got nothing to do with COleDateTimeSpan. Actually i have a string like 1259 (for GMT), 1125 (for EST) I need to use that string to update my m_ReadPointer object. so that any time i query for on it is in the timezone of the GMT/EST irrespective of the local system timezone. Dimple

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

                  DimpleSurana wrote: Actually i have a string like 1259 (for GMT), 1125 (for EST) Are you sure of these? Isn't 1259 for Melbourne, Australia, and 1125 for Mendoza, Texas? Just a guess. How are you getting a 4-digit number from the TimeZone class? From what I can tell, all the ids are 3 characters.


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

                  D 1 Reply Last reply
                  0
                  • D David Crow

                    DimpleSurana wrote: Actually i have a string like 1259 (for GMT), 1125 (for EST) Are you sure of these? Isn't 1259 for Melbourne, Australia, and 1125 for Mendoza, Texas? Just a guess. How are you getting a 4-digit number from the TimeZone class? From what I can tell, all the ids are 3 characters.


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

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

                    Ok these strings make sense wrt to the java.util.TimeZone class. I can get the timezone name from this class like "GMT"/"GMT+5:30". I saw the other eg. u gave using the struct TIME_ZONE_INFORMATION. But my query is what from the java side TimeZone class i can give to the VC++ to get the time on the VC++ side in the concerned timezone:confused:

                    D 1 Reply Last reply
                    0
                    • D DimpleSurana

                      Ok these strings make sense wrt to the java.util.TimeZone class. I can get the timezone name from this class like "GMT"/"GMT+5:30". I saw the other eg. u gave using the struct TIME_ZONE_INFORMATION. But my query is what from the java side TimeZone class i can give to the VC++ to get the time on the VC++ side in the concerned timezone:confused:

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

                      Ok i have my answer. The rawoffset of the Timezone object cud be used to co relate with the Bias & hence i can achieve what i want Thanks for ur help :-) Dimple

                      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