年没有在linux上显示

use*_*114 5 c unix linux

希望有人能提供帮助.我正在解决某人在很久以前写的"C代码"中的一个问题,并且他已经转移了.

该段代码输出特定文件的时间戳.代码在Windows上运行时工作正常,但是当它在Linux上运行时,它会错误地显示Year.这一年没有在linux上显示,它显示35222.有没有人知道这里有什么问题?

谢谢

Windows输出:

Source file: test.dtl, Created: Mon, 27 May, 2013 at 16:13:20
Run Code Online (Sandbox Code Playgroud)

Linux输出:

Source file: test.dtl, Created: Mon, 27 May, 35222 at 16:13:20
Run Code Online (Sandbox Code Playgroud)

C代码中的函数:

void SummaryReport ( report_t *report, char *dtlName)
{      
       LogEntry(L"SummaryReport entry\n");

       int                  i;
       wchar_t              *rootStrType,*localStr,timeStr[48];
       wchar_t              fileBuff[64];

       struct tm *timeVals;
       timeVals = localtime (&logHdr.date);
       wcsftime (timeStr,47,L"%a, %#d %b, %Y at %X",timeVals);

       /*  Print the header information  */
       DisplayReportFile (report);
       ReportEntry (report,L" Filesystem Audit Summary Report\n\n");
       ReportEntry (report,L"Source file: %s, Created: %ls\n\n",dtlName,timeStr);
       ReportEntry (report,L"Server: %ls",srvrName);
…
}
Run Code Online (Sandbox Code Playgroud)

vir*_*tor 1

在一个最小的例子上进行了验证,它“对我有用”。这显示了正确的时间吗?

#include <wchar.h>
#include <time.h>


int main() {
        wchar_t timeStr[48];
        struct tm *timeVals;
        time_t now = time(NULL);
        timeVals = localtime(&now);
        wcsftime(timeStr, 47, L"%a, %#d %b, %Y at %X", timeVals);
        wprintf(timeStr);
        return 0;
}
Run Code Online (Sandbox Code Playgroud)

如果是,请检查文件本身 - 如果您正在共享文件系统,也许文件时间戳本身存在一些奇怪的问题?(或者了解 fs 元数据)