fixed: there were mktime() used on some dirs Items

so sometimes the time of the dir was changed

now for converting tm into time_t use:
time_t Time(const tm & par);
time_t Time(const tm * par);
tm     Time(time_t par);
from core/misc.h

now winix internally use GMT time
only when printing it is converted to local user time
temporarily all users use the same local time (config: time_zone_offset)
(only logs are genereted with local system time)

added to system:
time_t LocalTime(time_t gmt_time);
tm     LocalTime(const tm * ptm);
tm     LocalTime(const tm & ptm);
they convert GMT time to local user time




git-svn-id: svn://ttmath.org/publicrep/winix/trunk@666 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2010-10-23 23:12:47 +00:00
parent a1bee81a5b
commit c48241f78a
33 changed files with 298 additions and 167 deletions

View File

@@ -311,31 +311,43 @@ static char buffer[100];
}
const char * DateToStr(tm * ptm)
const char * DateToStr(const tm * ptm)
{
return DateToStr(ptm->tm_year + 1900, ptm->tm_mon+1, ptm->tm_mday, ptm->tm_hour, ptm->tm_min, ptm->tm_sec);
}
const char * DateToStr(time_t t)
const char * DateToStr(const tm & rtm)
{
tm * ptm = std::localtime(&t);
return DateToStr(ptm);
return DateToStr(rtm.tm_year + 1900, rtm.tm_mon+1, rtm.tm_mday, rtm.tm_hour, rtm.tm_min, rtm.tm_sec);
}
const char * DateToStrWithoutHours(tm * ptm)
const char * DateToStr(time_t t)
{
tm rtm = Time(t);
return DateToStr(rtm);
}
const char * DateToStrWithoutHours(const tm * ptm)
{
return DateToStr(ptm->tm_year + 1900, ptm->tm_mon+1, ptm->tm_mday);
}
const char * DateToStrWithoutHours(const tm & rtm)
{
return DateToStr(rtm.tm_year + 1900, rtm.tm_mon+1, rtm.tm_mday);
}
const char * DateToStrWithoutHours(time_t t)
{
tm * ptm = std::localtime(&t);
tm rtm = Time(t);
return DateToStrWithoutHours(ptm);
return DateToStrWithoutHours(rtm);
}
@@ -360,17 +372,23 @@ return buffer;
}
const char * DateToStrCookie(tm * ptm)
const char * DateToStrCookie(const tm * ptm)
{
return DateToStrCookie(ptm->tm_year + 1900, ptm->tm_mon+1, ptm->tm_mday, ptm->tm_hour, ptm->tm_min, ptm->tm_sec);
}
const char * DateToStrCookie(const tm & rtm)
{
return DateToStrCookie(rtm.tm_year + 1900, rtm.tm_mon+1, rtm.tm_mday, rtm.tm_hour, rtm.tm_min, rtm.tm_sec);
}
const char * DateToStrCookie(time_t t)
{
tm * ptm = std::localtime(&t);
tm rtm = Time(t);
return DateToStrCookie(ptm);
return DateToStrCookie(rtm);
}
@@ -801,3 +819,47 @@ Item::Auth SelectFileType(const char * file_name)
return Item::auth_other;
}
time_t Time(const tm & par)
{
tm t;
memset(&t, 0, sizeof(t));
t.tm_year = par.tm_year;
t.tm_mon = par.tm_mon;
t.tm_mday = par.tm_mday;
t.tm_hour = par.tm_hour;
t.tm_min = par.tm_min;
t.tm_sec = par.tm_sec;
return timegm(&t);
}
time_t Time(const tm * par)
{
return Time(*par);
}
tm Time(time_t par)
{
tm * ptm = gmtime(&par);
tm res;
memset(&res, 0, sizeof(res));
if( ptm )
{
res.tm_year = ptm->tm_year;
res.tm_mon = ptm->tm_mon;
res.tm_mday = ptm->tm_mday;
res.tm_hour = ptm->tm_hour;
res.tm_min = ptm->tm_min;
res.tm_sec = ptm->tm_sec;
}
return res;
}