Skip to content

STM32 CalendarTime::Advance() fails on Feb 29, can cause sleep to hang forever #279

Closed
@terrillmoore

Description

@terrillmoore

Consider the following:

auto caltime = gCatena.GetCalendarTime();

caltime.Year = 0;
caltime.Month = 2;
caltime.Day = 29;
caltime.Hour = 23;
caltime.Minute = 59;
caltime.Second = 50;
caltime.Advance(600);

gCatena.SafePrintf("Advanced time (2/29): %02d-%02d-%02d %02d:%02d:%02d\n",
		caltime.Year, caltime.Month, caltime.Day,
		caltime.Hour, caltime.Minute, caltime.Second
		);

The result is

Advanced time (2/29): 00-02-30 00:09:50

If you try to set an alarm for this, it will never wake up (and not detect an error).

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions