mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-14 12:13:22 +00:00
updated date formatting code for FTP dir listing. we're now more accurate. also commented out some extraneous logging
This commit is contained in:
parent
fea615e364
commit
e8c2fedfd3
@ -543,7 +543,7 @@ nsFTPDirListingConv::MonthNumber(const char *month) {
|
||||
char c1 = month[1], c2 = month[2];
|
||||
PRInt8 rv = -1;
|
||||
|
||||
PR_LOG(gFTPDirListConvLog, PR_LOG_DEBUG, ("nsFTPDirListingConv::MonthNumber(month = %s) ", month) );
|
||||
//PR_LOG(gFTPDirListConvLog, PR_LOG_DEBUG, ("nsFTPDirListingConv::MonthNumber(month = %s) ", month) );
|
||||
|
||||
switch (*month) {
|
||||
case 'f': case 'F':
|
||||
@ -583,7 +583,7 @@ nsFTPDirListingConv::MonthNumber(const char *month) {
|
||||
rv = -1;
|
||||
}
|
||||
|
||||
PR_LOG(gFTPDirListConvLog, PR_LOG_DEBUG, ("returning %d\n", rv) );
|
||||
//PR_LOG(gFTPDirListConvLog, PR_LOG_DEBUG, ("returning %d\n", rv) );
|
||||
|
||||
return rv;
|
||||
}
|
||||
@ -666,15 +666,11 @@ nsFTPDirListingConv::ConvertUNIXDate(char *aCStr, PRTime& outDate) {
|
||||
|
||||
PRExplodedTime curTime;
|
||||
|
||||
PR_ExplodeTime(PR_Now(), PR_LocalTimeParameters, &curTime);
|
||||
InitPRExplodedTime(curTime);
|
||||
|
||||
char *bcol = aCStr; /* Column begin */
|
||||
char *ecol; /* Column end */
|
||||
|
||||
// defaults
|
||||
curTime.tm_usec = 0;
|
||||
curTime.tm_sec = 0;
|
||||
|
||||
// MONTH
|
||||
char tmpChar = bcol[3];
|
||||
bcol[3] = '\0';
|
||||
@ -692,16 +688,12 @@ nsFTPDirListingConv::ConvertUNIXDate(char *aCStr, PRTime& outDate) {
|
||||
PRInt32 error;
|
||||
nsCAutoString day(bcol);
|
||||
curTime.tm_mday = day.ToInteger(&error, 10);
|
||||
//curTime.tm_wday = 0;
|
||||
//curTime.tm_yday = 0;
|
||||
|
||||
// YEAR
|
||||
bcol = ++ecol;
|
||||
if ((ecol = PL_strchr(bcol, ':')) == NULL) {
|
||||
nsCAutoString intStr(bcol);
|
||||
curTime.tm_year = intStr.ToInteger(&error, 10);
|
||||
curTime.tm_min = 0;
|
||||
curTime.tm_hour = 0;
|
||||
} else {
|
||||
// TIME
|
||||
/* If the time is given as hh:mm, then the file is less than 1 year
|
||||
@ -715,7 +707,10 @@ nsFTPDirListingConv::ConvertUNIXDate(char *aCStr, PRTime& outDate) {
|
||||
intStr = bcol;
|
||||
curTime.tm_hour = intStr.ToInteger(&error, 10); // Left side of ':'
|
||||
|
||||
curTime.tm_year = curTime.tm_year;
|
||||
// Use the current year if one wasn't provided.
|
||||
PRExplodedTime nowETime;
|
||||
PR_ExplodeTime(PR_Now(), PR_LocalTimeParameters, &nowETime);
|
||||
curTime.tm_year = nowETime.tm_year;
|
||||
//if (mktime(time_info) > curtime)
|
||||
// --time_info->tm_year;
|
||||
}
|
||||
@ -730,7 +725,7 @@ nsFTPDirListingConv::ConvertVMSDate(char *aCStr, PRTime& outDate) {
|
||||
|
||||
PRExplodedTime curTime;
|
||||
|
||||
PR_ExplodeTime(PR_Now(), PR_GMTParameters, &curTime);
|
||||
InitPRExplodedTime(curTime);
|
||||
|
||||
char *col;
|
||||
|
||||
@ -742,11 +737,6 @@ nsFTPDirListingConv::ConvertVMSDate(char *aCStr, PRTime& outDate) {
|
||||
PRInt32 error;
|
||||
curTime.tm_mday = intStr.ToInteger(&error, 10);
|
||||
|
||||
// XXX the following two sets may be skewing the Imploded time
|
||||
// XXX we're not supposed to set wday and yday (see prtime.h)
|
||||
curTime.tm_wday = 0;
|
||||
curTime.tm_yday = 0;
|
||||
|
||||
if ((col = strtok(nsnull, "-")) == nsnull || (curTime.tm_month = MonthNumber(col)) < 0)
|
||||
return PR_FALSE;
|
||||
|
||||
@ -771,7 +761,6 @@ nsFTPDirListingConv::ConvertVMSDate(char *aCStr, PRTime& outDate) {
|
||||
|
||||
intStr = col;
|
||||
curTime.tm_min = intStr.ToInteger(&error, 10);
|
||||
curTime.tm_sec = 0;
|
||||
|
||||
outDate = PR_ImplodeTime(&curTime);
|
||||
return PR_TRUE;
|
||||
@ -782,7 +771,7 @@ nsFTPDirListingConv::ConvertDOSDate(char *aCStr, PRTime& outDate) {
|
||||
|
||||
PRExplodedTime curTime;
|
||||
|
||||
PR_ExplodeTime(PR_Now(), PR_GMTParameters, &curTime);
|
||||
InitPRExplodedTime(curTime);
|
||||
|
||||
curTime.tm_month = (aCStr[1]-'0')-1;
|
||||
|
||||
@ -795,10 +784,6 @@ nsFTPDirListingConv::ConvertDOSDate(char *aCStr, PRTime& outDate) {
|
||||
|
||||
curTime.tm_min = (((aCStr[13]-'0')*10) + aCStr[14]-'0');
|
||||
|
||||
curTime.tm_wday = 0;
|
||||
curTime.tm_yday = 0;
|
||||
curTime.tm_sec = 0;
|
||||
|
||||
outDate = PR_ImplodeTime(&curTime);
|
||||
return PR_TRUE;
|
||||
}
|
||||
@ -1001,6 +986,21 @@ nsFTPDirListingConv::ParseVMSLine(char *aLine, indexEntry *aEntry) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsFTPDirListingConv::InitPRExplodedTime(PRExplodedTime& aTime) {
|
||||
aTime.tm_usec = 0;
|
||||
aTime.tm_sec = 0;
|
||||
aTime.tm_min = 0;
|
||||
aTime.tm_hour = 0;
|
||||
aTime.tm_mday = 0;
|
||||
aTime.tm_month= 0;
|
||||
aTime.tm_year = 0;
|
||||
|
||||
// localize this sucker.
|
||||
PRTimeParameters params = PR_LocalTimeParameters(&aTime);
|
||||
aTime.tm_params = params;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Factory
|
||||
|
@ -142,6 +142,8 @@ private:
|
||||
nsresult ParseLSLine(char *aLine, indexEntry *aEntry);
|
||||
nsresult ParseVMSLine(char *aLine, indexEntry *aEntry);
|
||||
|
||||
void InitPRExplodedTime(PRExplodedTime& aTime);
|
||||
|
||||
// member data
|
||||
FTP_Server_Type mServerType; // what kind of server is the data coming from?
|
||||
nsCAutoString mBuffer; // buffered data.
|
||||
|
Loading…
x
Reference in New Issue
Block a user