Skip to content

Commit

Permalink
Rename GncDateTime's ymd to gnc_ymd to avoid a name conflict with Car…
Browse files Browse the repository at this point in the history
…bon.
  • Loading branch information
jralls committed Jan 9, 2023
1 parent e92e7d0 commit fb9947b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions libgnucash/engine/gnc-datetime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ class GncDateImpl
GncDateImpl(const std::string str, const std::string fmt);

void today() { m_greg = boost::gregorian::day_clock::local_day(); }
ymd year_month_day() const;
gnc_ymd year_month_day() const;
std::string format(const char* format) const;
std::string format_zulu(const char* format) const {
return this->format(format);
Expand Down Expand Up @@ -601,7 +601,7 @@ GncDateImpl::GncDateImpl(const std::string str, const std::string fmt) :
std::stoi (what.str("DAY")));
}

ymd
gnc_ymd
GncDateImpl::year_month_day() const
{
auto boost_ymd = m_greg.year_month_day();
Expand Down Expand Up @@ -738,7 +738,7 @@ GncDate::format(const char* format)
return m_impl->format(format);
}

ymd
gnc_ymd
GncDate::year_month_day() const
{
return m_impl->year_month_day();
Expand Down
8 changes: 4 additions & 4 deletions libgnucash/engine/gnc-datetime.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ typedef struct
int year; //1400-9999
int month; //1-12
int day; //1-31
} ymd;
} gnc_ymd;

enum class DayPart {
start, // 00:00 local
Expand Down Expand Up @@ -272,10 +272,10 @@ class GncDate
GncDate& operator=(GncDate&&);
/** Set the date object to the computer clock's current day. */
void today();
/** Get the year, month, and day from the date as a ymd.
* @return ymd struct
/** Get the year, month, and day from the date as a gnc_ymd.
* @return gnc_ymd struct
*/
ymd year_month_day() const;
gnc_ymd year_month_day() const;
/** Format the GncDate into a std::string
* @param format A cstr describing the way the date and time are
* presented. Code letters preceded with % stand in for arguments;
Expand Down
16 changes: 8 additions & 8 deletions libgnucash/engine/test/gtest-gnc-datetime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ TEST(gnc_datetime_constructors, test_struct_tm_constructor)

TEST(gnc_datetime_constructors, test_gncdate_start_constructor)
{
const ymd aymd = { 2017, 04, 20 };
const gnc_ymd aymd = { 2017, 04, 20 };
GncDateTime atime(GncDate(aymd.year, aymd.month, aymd.day), DayPart::start);
//Skipping timezone information as this can't be controlled.
EXPECT_EQ(atime.format("%d-%m-%Y %H:%M:%S"), "20-04-2017 00:00:00");
Expand All @@ -358,8 +358,8 @@ TEST(gnc_datetime_constructors, test_gncdate_start_constructor)
*/
TEST(gnc_datetime_constructors, test_gncdate_BST_transition)
{
const ymd begins = {2018, 03, 25};
const ymd ends = {2018, 10, 28};
const gnc_ymd begins = {2018, 03, 25};
const gnc_ymd ends = {2018, 10, 28};
#ifdef __MINGW32__
TimeZoneProvider tzp{"GMT Standard Time"};
#else
Expand All @@ -375,7 +375,7 @@ TEST(gnc_datetime_constructors, test_gncdate_BST_transition)

TEST(gnc_datetime_constructors, test_gncdate_end_constructor)
{
const ymd aymd = { 2046, 11, 06 };
const gnc_ymd aymd = { 2046, 11, 06 };
GncDateTime atime(GncDate(aymd.year, aymd.month, aymd.day), DayPart::end);
//Skipping timezone information as this can't be controlled.
EXPECT_EQ(atime.format("%d-%m-%Y %H:%M:%S"), "06-11-2046 23:59:59");
Expand Down Expand Up @@ -486,11 +486,11 @@ TEST(gnc_datetime_constructors, test_gncdate_neutral_constructor)
TimeZoneProvider tzp_la("America/Los_Angeles");
#endif
_set_tzp(tzp_la);
const ymd aymd = { 2017, 04, 20 };
const gnc_ymd aymd = { 2017, 04, 20 };
GncDateTime atime(GncDate(aymd.year, aymd.month, aymd.day), DayPart::neutral);
time64 date{1492685940};
GncDateTime gncdt(date); /* 20 Apr 2017 10:59:00 Z */
/* The ymd constructor sets the time of day at 10:59:00 for
/* The gnc_ymd constructor sets the time of day at 10:59:00 for
* timezones between UTC-10 and UTC+13. For other timezones the
* time of day is adjusted to ensure a consistent date and the
* adjustment invalidates the test, so skip it.
Expand All @@ -509,8 +509,8 @@ TEST(gnc_datetime_constructors, test_gncdate_neutral_constructor)

TEST(gnc_datetime_constructors, test_neutral_across_timezones)
{
const ymd begins = {2018, 03, 05};
const ymd ends = {2018, 03, 15};
const gnc_ymd begins = {2018, 03, 05};
const gnc_ymd ends = {2018, 03, 15};
const time64 ten_days = 864000;
#ifdef __MINGW32__
TimeZoneProvider tzp_lon{"GMT Standard Time"};
Expand Down

0 comments on commit fb9947b

Please sign in to comment.