本文整理汇总了C++中TimeZone::UtcTimeToStandardTime方法的典型用法代码示例。如果您正苦于以下问题:C++ TimeZone::UtcTimeToStandardTime方法的具体用法?C++ TimeZone::UtcTimeToStandardTime怎么用?C++ TimeZone::UtcTimeToStandardTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TimeZone
的用法示例。
在下文中一共展示了TimeZone::UtcTimeToStandardTime方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ApplyPattern
String
TimeAndPlace::GetReadableTime(void) {
LocaleManager localeManager;
localeManager.Construct();
Locale locale = localeManager.GetSystemLocale();
TimeZone timeZone = localeManager.GetSystemTimeZone();
AppLog("GMT Time Zone id is %S", timeZone.GetGmtTimeZone().GetId().GetPointer());
AppLog("Time Zone is %S", timeZone.GetId().GetPointer());
AppLog("Time Zone offset is %d", timeZone.GetRawOffset());
AppLog("Time Zone DST is %d", timeZone.GetDstSavings());
String customizedPattern = L"HH:mm:ss";
String readableDateTime;
DateTimeFormatter* formatter = DateTimeFormatter::CreateDateFormatterN();
formatter -> ApplyPattern(customizedPattern);
DateTime standardOffsetDateTime = timeZone.UtcTimeToStandardTime(*dateTime, timeZone.GetRawOffset());
formatter -> Format(standardOffsetDateTime, readableDateTime);
AppLog("Standard Local Time is %S", readableDateTime.GetPointer());
readableDateTime.Append("\n");
readableDateTime.Append(timeZone.GetId());
return readableDateTime;
}
示例2:
void
TimeAndPlace::SetSiderialTime(float longitude, float latitude, DateTime* currTime) {
AppLog("Trying to access TimeAndPlace");
TimeAndPlace::SetLongitude(longitude);
AppLog("Trying to access TimeAndPlace 1");
TimeAndPlace::SetLatitude(latitude);
AppLog("Trying to access TimeAndPlace 2");
//TimeZone timeZone(60, L"Europe/London");
LocaleManager localeManager;
localeManager.Construct();
Locale locale = localeManager.GetSystemLocale();
TimeZone timeZone = localeManager.GetSystemTimeZone();
AppLog("Locale code %S", (locale.GetLanguageCodeString().GetPointer()));
AppLog("TimeZone ID is %S", (timeZone.GetId()).GetPointer());
// TimeZone timeZone(TimeZone::GetGmtTimeZone());
AppLog("TP1");
SystemTime::GetCurrentTime(*currTime);
AppLog("TP2");
dateTime = currTime;
AppLog("TP2a");
localDateTime = &(timeZone.UtcTimeToStandardTime(*currTime));
Calendar* calendar;
AppLog("TP3");
calendar = Calendar::CreateInstanceN(timeZone, CALENDAR_GREGORIAN);
AppLog("TP4");
calendar->SetTime(*currTime);
AppLog("TP5");
float hrs = (calendar->GetTimeField(TIME_FIELD_HOUR_OF_DAY))-1;
AppLog("TP6");
float minHrs = calendar->GetTimeField(TIME_FIELD_MINUTE)/60.0;
AppLog("TP7");
float dayFract = (hrs + minHrs)/24.0;
AppLog("TP8");
float dayNum = calendar->GetTimeField(TIME_FIELD_DAY_OF_YEAR);
AppLog("TP9");
float year = calendar->GetTimeField(TIME_FIELD_YEAR);
AppLog("TP10");
double daysSinceJ2000 = -1.5 + dayNum + (year-2000)*365 + (int)((year-2000)/4) + dayFract;
AppLog("TP11");
double slt = 100.46 + 0.985647 * daysSinceJ2000 + longitude + 15*(hrs + minHrs);
AppLog("TP12");
int sltInt = (int)(slt/360);
AppLog("TP13");
float sltHrs = (slt-(360*sltInt))/15;
AppLog("TP14");
SetSiderialTime (sltHrs);
AppLog("TP15");
}