Adding timezone to a COleDateTime object
-
I am lost since morning to find the co - relation. Since a java applicationis giving me that value Dimple
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????
-
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????
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
-
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
Look at the
Bias
member ofTIME_ZONE_INFORMATION
structure.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
-
Look at the
Bias
member ofTIME_ZONE_INFORMATION
structure.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
but how will that help me. I have done study of all the structures of c++.
-
but how will that help me. I have done study of all the structures of c++.
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)
-
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)
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:
-
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
-
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:
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). TheBias
member of theTIME_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)
-
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
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)
-
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)
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:
-
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:
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