2011-08-16 6 views

答えて

2

私はもう少しデバッグ時間に関連する構造の後でそれを理解しました。

struct tm * gmtime (const time_t * timer)を使用すると、UTC時間がかかります。

tzset()tzname[0]を使用してタイムゾーン情報を取得できます。

1

ブーストのタイムゾーンデータベースを含むBoost.Date_Timeです。同じものを使うことができます。

2

あなたは、Unix上で使用することができます以下ホストマシンのシステム設定に従って、現在のタイムゾーンを与える

std::string LocalTimeZone() 
{ 
    time_t now = time(NULL); 
    struct tm tnow = *localtime(&now); 
    std::string tz = tnow.tm_zone; 
    std::cout << "Local timezone: " << tz << std::endl; 

    char buff[100]; 
    strftime(buff, sizeof buff, "%a %b %d %Y %T %Z%z", &tnow); 

    std::vector<std::string> vec; 
    const std::string s(buff); 
    boost::split(vec, s, boost::is_any_of(" ")); 

    std::vector<std::string>::iterator i = vec.end(); 
    return *--i; 
} 

関連する問題