(Linuxでは、強調鉱山上):
夏時間(DST)が時間 有効である かどうか フィールドは、mktime関数を(通知tm_isdstがで指定された値) tm 構造体で提供されます。正の値は、DST が有効であることを意味します。 0は、DSTが でないことを意味します。 負の値 は、DSTは 指定された時間で有効であるか否かはmktime()は を決定する試み( タイムゾーン情報及びシステム データベースにを使用する)必要があることを意味します。
これを試しましたか?あなたが本当にあいまいな時間のために試みることができる
(いくつかの時間は基本的にあいまいであるので、それの「決定しようとする試み」。)
何かがmktime
があなたのDSTフラグを「修正」かどうかを確認することです。私はこれは移植可能ではないと賭けるだろう。サンプルコードは、遷移が31/10/2010に設定され、午前3時には、私のタイムゾーン(ヨーロッパ/パリ)に午前2時にロールバック:
#include <time.h>
#include <stdio.h>
#include <string.h>
void printit(int hour, int isdst)
{
struct tm when;
memset(&when, 0, sizeof(when));
when.tm_sec = 0;
when.tm_min = 30;
when.tm_hour = hour;
when.tm_mday = 31;
when.tm_mon = 9;
when.tm_year = 110;
when.tm_isdst = isdst;
time_t secs = mktime(&when);
fprintf(stdout, "%2d %ld %d %s", isdst, secs, when.tm_isdst, asctime(&when));
}
int main(int argc, char **argv)
{
for (int i=1; i<4; i++) {
fprintf(stdout, "At %dam\n", i);
printit(i, 1);
printit(i, 0);
printit(i, -1);
}
}
出力は次のとおりです。
At 1am
1 1288481400 1 Sun Oct 31 01:30:00 2010
0 1288485000 1 Sun Oct 31 02:30:00 2010
-1 1288481400 1 Sun Oct 31 01:30:00 2010
At 2am
1 1288485000 1 Sun Oct 31 02:30:00 2010
0 1288488600 0 Sun Oct 31 02:30:00 2010
-1 1288488600 0 Sun Oct 31 02:30:00 2010
At 3am
1 1288488600 0 Sun Oct 31 02:30:00 2010
0 1288492200 0 Sun Oct 31 03:30:00 2010
-1 1288492200 0 Sun Oct 31 03:30:00 2010
あなたが見ることができるように、とき時間が相違していない場合は、を設定して時間をオフセットすることで、mktime
を修正します。 がの場合、tm_isdst
は変更されません。
出典
2011-03-13 08:41:24
Mat
OTOHとIMO、OPEN-bookテストのための良い質問です。 –