boostorg / boostorg/date_time

day_of_year().max() returns 366 while 2002 had 365 days

Open
#229 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
70
Forks
99
PR merge metrics
No merged PRs in 30d

Description

The year 2002 had a total of 365 days, but when calling the day_of_year().max() function, it returns 366. Is this a bug? It seems like the function is returning the maximum possible day of the year for a leap year instead of correctly accounting for the number of days in 2002. Can this issue be looked into and resolved? Thank you.

BOOST_AUTO_TEST_CASE(testPropertyGetMaxMinValuesDayOfYear)
{
ptime test(date(2004, 6, 9), time_duration(0, 0, 0));

BOOST_CHECK_EQUAL(1, test.date().day_of_year().min());
BOOST_CHECK_EQUAL(366, test.date().day_of_year().max());

test = ptime(date(2002, 6, 9), time_duration(0, 0, 0));

BOOST_CHECK_EQUAL(1, test.date().day_of_year().min());
BOOST_CHECK_EQUAL(365, test.date().day_of_year().max());
}

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.