struct tm在通过函数时变为PST

struct tm在通过函数时变为PST,c,windows-subsystem-for-linux,C,Windows Subsystem For Linux,你好!我对GMT格式的struct tm有一个问题,但当通过一个函数时,它会减少8个小时并转到我的本地时间(PST) 我现在将time\t timeif传递给函数。当传递函数时,如果时间不变,则此函数起作用 我仍然不知道为什么struct tm会改变时区。无法复制。也许一个无关的东西是相关的。 void TestFunction(glob_t* globbuf, struct tm *tm) { char buffx[300]; time_t timeif = timegm(tm

你好!我对GMT格式的struct tm有一个问题,但当通过一个函数时,它会减少8个小时并转到我的本地时间(PST)


我现在将time\t timeif传递给函数。当传递函数时,如果时间不变,则此函数起作用


我仍然不知道为什么struct tm会改变时区。

无法复制。也许一个无关的东西是相关的。
void TestFunction(glob_t* globbuf, struct tm *tm)
{
    char buffx[300];
    time_t timeif = timegm(tm);


    strftime(buffx, 100, "%Y-%m-%d %H:%M:%S.000", gmtime(&timeif));
    //print the buffx
    // the print shows the time in PST, -8 hours from what it was because at this point tm becomes
    // PST
}

int main()
{
    time_t t = time(NULL);
    struct tm *tm = gmtime(&t);
    tm->tm_sec = 0;

    char buffx[300];
    time_t timeif = timegm(tm);


    strftime(buffx, 100, "%Y-%m-%d %H:%M:%S.000", gmtime(&timeif));
    //print the buffx
    // Prints the time in GMT.
    // Do some other unrelated stuff

    TestFunction(&unRelatedParameterOne, tm); // Variable tm is in GMT

    return 0;
}