Skip to content

Instantly share code, notes, and snippets.

@wy-ei
Created April 11, 2016 02:57
Show Gist options
  • Save wy-ei/1fdcb6c8b9d9b509dc68e7ae83d4fc43 to your computer and use it in GitHub Desktop.
Save wy-ei/1fdcb6c8b9d9b509dc68e7ae83d4fc43 to your computer and use it in GitHub Desktop.
int CDate::operator-(const CDate d)const{
int days;
int nm = (_Month + 9) % 12; //
int ny = _Year - nm / 10;
int nd = 365 * ny + ny / 4 - ny / 100 + ny / 400 + (nm * 306 + 5) / 10 + (_Day - 1);
int nm1 = (d._Month + 9) % 12;
int ny1 = d._Year - nm1 / 10;
int nd1 = 365 * ny1 + ny1 / 4 - ny1 / 100 + ny1 / 400 + (nm1 * 365 + 5) / 10 + (d._Day - 1);
days = nd - nd1;
return days;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment