Skip to content

DateTimeFormat RFC1036 Sunday name is short (should be long) #4486

@ericlogic

Description

@ericlogic

Describe the bug
I'm using a FileChannel to record logs with property "rotation" sets to "daily". It crashed on Sunday with an error message: Invalid DateTimeString:Sunday, 10 Mar 24 07:34:50 GMT

To Reproduce

Path logPath = Path(commandPath()).parent().pushDirectory("logs");
File(logPath).createDirectories();
logPath.setFileName("purpose-service.log");
Channel::Ptr pFileChannel = new FileChannel();
pFileChannel->setProperty("path", logPath.toString());
pFileChannel->setProperty("rotation", "daily");
pFileChannel->setProperty("archive", "timestamp");
PatternFormatter::Ptr pFormatter = new PatternFormatter("%Y-%m-%dT%H:%M:%S %q [%s] %t");
FormattingChannel::Ptr pFormattingChannel = new FormattingChannel(pFormatter, pFileChannel);
Logger::root().setChannel(pFormattingChannel);

Logger::get("main").information("Application started!");

Logs

Exception thrown at 0x00007FF88D755B0C in purpose-service.exe: Microsoft C++ exception: Poco::SyntaxException at memory location 0x000000FC5912D730.
Syntax error: Invalid DateTimeString:Sunday, 10 Mar 24 07:34:50 GMT

Please add relevant environment information:

  • OS Type and Version: Window 11
  • POCO Version: 1.13.0

Additional context
I did some research and found a regular expression in "Foundation/src/DateTimeFormat.cpp".

const std::string DateTimeFormat::RFC1036_REGEX(
	"(((Monday)|(Tuesday)|(Wednesday)|(Thursday)|(Friday)|(Saturday)|(Sun)), *)?"
	"\\d\\d? +"
	"((Jan)|(Feb)|(Mar)|(Apr)|(May)|(Jun)|(Jul)|(Aug)|(Sep)|(Oct)|(Nov)|(Dec)) +"
	"\\d\\d(\\d\\d)? +\\d\\d:\\d\\d(:\\d\\d)? "
	"(" TIMEZONES_REGEX_PART "|)?+"
	"(([+\\-]?\\d\\d\\d\\d)?|" TIMEZONES_REGEX_PART "|\\w)");

Should the "Sun" in this regular expression be changed to "Sunday"?

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions