Skip to content

Instantly share code, notes, and snippets.

@Akira-Hayasaka
Created August 24, 2023 08:19
Show Gist options
  • Save Akira-Hayasaka/fb17825e4692f319e48b8ec2d23cdf79 to your computer and use it in GitHub Desktop.
Save Akira-Hayasaka/fb17825e4692f319e48b8ec2d23cdf79 to your computer and use it in GitHub Desktop.
compare before 1970/01/01 epoch std::tm
static bool comp_dates_before_1970_epoch(const std::tm& dt1, const std::tm& dt2)
{
if (dt1.tm_year != dt2.tm_year) return dt1.tm_year < dt2.tm_year;
if (dt1.tm_mon != dt2.tm_mon) return dt1.tm_mon < dt2.tm_mon;
if (dt1.tm_mday != dt2.tm_mday) return dt1.tm_mday < dt2.tm_mday;
if (dt1.tm_hour != dt2.tm_hour) return dt1.tm_hour < dt2.tm_hour;
if (dt1.tm_min != dt2.tm_min) return dt1.tm_min < dt2.tm_min;
return dt1.tm_sec < dt2.tm_sec;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment