Skip to content

[Bug] 内核mktime函数bug #11685

Description

@Memory-afk

RT-Thread Version

5.0.1

Affected area

Kernel

Hardware/BSP vendor

Nuvoton

Architecture

ARM / AArch64

Board and hardware details

N9H30

Develop Toolchain

GCC

Describe the bug

void time_example(void)
{
struct tm *raw_time;
struct tm _time;

_time.tm_year = 126;
_time.tm_mon = 7;
_time.tm_mday = 5;
_time.tm_hour = 8;
_time.tm_min = 0;
_time.tm_sec = 0;


_time.tm_mday += 420;

time_t timestamp = mktime(&_time);
raw_time = localtime(&timestamp);
raw_time->tm_year += 1900;

// 这里应该输出的是2027/08/29,而实际上输出的是2027/03/01
rt_kprintf("%04d/%02d/%02d\n", raw_time->tm_year, raw_time->tm_mon, raw_time->tm_mday);

}

Other additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Arch: ARM/AArch64BSP related with armBSPBSP: NuvotonBSP related with NuvotonKernelPR has src relate codebugThis PR/issue is a bug in the current code.in progressPR/issue in progress.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions