date.cpp Corretto costruttore sulle date e is_date

relation.cpp  Aggiunto un const in una variabile locale


git-svn-id: svn://10.65.10.50/trunk@1592 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1995-07-13 09:48:22 +00:00
parent f393c1a3ba
commit f9ec8d90e9
2 changed files with 32 additions and 27 deletions

View File

@ -24,7 +24,7 @@
HIDDEN TDate __tmp_date;
HIDDEN char __date_tmp_string[128];
HIDDEN const byte dm[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
HIDDEN const byte _days_in_month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
TDate::TDate(const TDate &d) : _val(d._val)
@ -84,8 +84,8 @@ TDate::TDate(long l) : _val(l)
for(y = 0; wd > DAYYEAR + (leap = ((y % 4 ) == 0)); y++)
wd -= (DAYYEAR + leap);
for(m = 0; wd > (dm[m] + (leap && (m == 1))); m++)
wd -= (dm[m] + (leap && (m == 1)));
for(m = 0; wd > (_days_in_month[m] + (leap && (m == 1))); m++)
wd -= (_days_in_month[m] + (leap && (m == 1)));
_val = makedata((int) wd, m+1, y+cnt);
}
}
@ -98,24 +98,27 @@ TDate::TDate(const char* s)
return;
int day, month, year;
if (strchr(s, '-') == NULL)
{
strcpy(__date_tmp_string, s);
day = atoi(__date_tmp_string + 6); __date_tmp_string[6] = '\0';
month = atoi(__date_tmp_string + 4); __date_tmp_string[4] = '\0';
year = atoi(__date_tmp_string);
}
else
{
day = atoi(s);
month = atoi(&s[3]);
year = atoi(&s[6]);
if (strlen(s) < 10)
year += 1900;
}
_val = makedata(day, month, year);
/*
if (strchr(s, '-') == NULL)
{
strcpy(__date_tmp_string, s);
day = atoi(__date_tmp_string + 6); __date_tmp_string[6] = '\0';
month = atoi(__date_tmp_string + 4); __date_tmp_string[4] = '\0';
year = atoi(__date_tmp_string);
}
else
*/
CHECKS(strlen(s) == 10, "Non e' una data lunga 10 caratteri: ", s);
{
day = atoi(s);
month = atoi(&s[3]);
year = atoi(&s[6]);
if (strlen(s) < 10)
year += 1900;
}
_val = makedata(day, month, year);
}
TDate::TDate(int day, int month, int year)
@ -397,17 +400,19 @@ void TDate::addyear(int nyear)
bool TDate::isdate(const char* s)
{
if (!*s) return FALSE;
int day = atoi(s),
// if (!*s) return FALSE;
if (strlen(s) < 8 || s[2] != s[5])
return FALSE;
month = atoi(&s[3]),
year = atoi(&s[6]);
const int day = atoi(s);
const int month = atoi(&s[3]);
const int year = atoi(&s[6]);
if (day < 1 || day > 31 ||
month < 1 || month > 12 ||
year < 0)
return FALSE;
return day <= dm[month - 1] || (month == 2 && (year % 4 == 0) && day == 29);
return day <= _days_in_month[month - 1] || (month == 2 && (year % 4 == 0) && day == 29);
}

View File

@ -1,4 +1,4 @@
// $Id: relation.cpp,v 1.53 1995-07-10 12:42:40 angelo Exp $
// $Id: relation.cpp,v 1.54 1995-07-13 09:48:22 guy Exp $
// relation.cpp
// fv 12/8/93
// relation class for isam files
@ -502,7 +502,7 @@ int TRelation::position_rels(TIsamop op, TReclock lockop,
}
// read record: if not found, zero current record
TRectype rec(from.curr());
const TRectype rec(from.curr());
from.read(op, lck, atdate);
if (from.bad())
{