Fixed epoch time conversion (start with the right year).

git-svn-id: http://voip.null.ro/svn/yate@2423 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
marian 2009-01-12 09:38:53 +00:00
parent 8280793cc5
commit 3927454b61
1 changed files with 2 additions and 1 deletions

View File

@ -544,9 +544,10 @@ unsigned int Time::toEpoch(int year, unsigned int month, unsigned int day,
// Count the number of days since EPOCH
int64_t days = (year - 1970) * 365;
// Add a day for each leap year from 1970 to 'year' (not including)
for (int y = 1970; y < year; y += 4)
for (int y = 1972; y < year; y += 4) {
if (isLeap(y))
days++;
}
// Add days ellapsed in given year
for (unsigned int i = 0; i < month; i++)
days += m[i];