mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
Core: Scalar Date operations improved - Set(0) and Get() now consistent, possible to Set Null
git-svn-id: svn://ultimatepp.org/upp/trunk@6339 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
7631f84952
commit
eb4a215a9b
3 changed files with 22 additions and 18 deletions
|
|
@ -238,19 +238,34 @@ int CharFilterDate(int c)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int Date::Get() const {
|
||||
return year * 365 + s_month_off[month - 1] + (day - 1) +
|
||||
(year - 1) / 4 - (year - 1) / 100 + (year - 1) / 400 + 1 +
|
||||
(month > 2) * IsLeapYear(year);
|
||||
int Date::Get() const
|
||||
{
|
||||
if(IsNull(*this))
|
||||
return Null;
|
||||
int y400 = (year / 400 ) - 2;
|
||||
int ym = year - y400 * 400;
|
||||
return y400 * (400 * 365 + 100 - 3) +
|
||||
ym * 365 + s_month_off[month - 1] + (day - 1) +
|
||||
(ym - 1) / 4 - (ym - 1) / 100 + (ym - 1) / 400 + 1 +
|
||||
(month > 2) * IsLeapYear(ym);
|
||||
}
|
||||
|
||||
void Date::Set(int d) {
|
||||
void Date::Set(int d)
|
||||
{
|
||||
if(IsNull(d)) {
|
||||
*this = Null;
|
||||
return;
|
||||
}
|
||||
int q, leap;
|
||||
year = 0;
|
||||
q = d / (400 * 365 + 100 - 3);
|
||||
year += 400 * q;
|
||||
d -= q * (400 * 365 + 100 - 3);
|
||||
leap = 1;
|
||||
if(d < 0) {
|
||||
year -= 400;
|
||||
d += 400 * 365 + 100 - 3;
|
||||
}
|
||||
leap = 1;
|
||||
if(d >= 100 * 365 + 24 + 1) {
|
||||
d--;
|
||||
q = d / (100 * 365 + 24);
|
||||
|
|
|
|||
|
|
@ -99,7 +99,6 @@ String FtpClient::Load(const char *path)
|
|||
return String::GetVoid();
|
||||
}
|
||||
load_data = Null;
|
||||
int p = 0;
|
||||
while(!WhenProgress(load_data.GetLength(), 0)) {
|
||||
byte buffer[1024];
|
||||
int ndata = FtpRead(buffer, sizeof(buffer), ftpdata);
|
||||
|
|
@ -232,7 +231,6 @@ String FtpClient::List(const char *path)
|
|||
error = FtpError(ftpconn);
|
||||
return String::GetVoid();
|
||||
}
|
||||
int p = 0;
|
||||
while(!WhenProgress(load_data.GetLength(),0)) {
|
||||
byte buffer[1024];
|
||||
int ndata = FtpRead(buffer, sizeof(buffer), ftpdata);
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ struct NetBuf {
|
|||
char perror[256];
|
||||
};
|
||||
|
||||
static char *version =
|
||||
static const char version[] =
|
||||
"ftplib Release 3.1-1 9/16/00, copyright 1996-2000 Thomas Pfau";
|
||||
|
||||
GLOBALDEF int ftplib_debug = 0;
|
||||
|
|
@ -388,14 +388,6 @@ static int FtpBlock(int sockno, int block, char perror[])
|
|||
return 1;
|
||||
}
|
||||
|
||||
static int FtpCheckRead(int sockno, struct timeval *tv)
|
||||
{
|
||||
fd_set mask;
|
||||
FD_ZERO(&mask);
|
||||
FD_SET(sockno, &mask);
|
||||
return select(sockno + 1, &mask, NULL, &mask, tv) > 0 ? 1 : 0;
|
||||
}
|
||||
|
||||
static int FtpCheckWrite(int sockno, struct timeval *tv)
|
||||
{
|
||||
fd_set mask;
|
||||
|
|
@ -749,7 +741,6 @@ static int FtpOpenPort(netbuf *nControl, netbuf **nData, int mode, int dir)
|
|||
|
||||
//*
|
||||
if (connect(sData, &sin.sa, sizeof(sin.sa)) == -1) {
|
||||
int t0 = UPP::msecs(), tlim = 0;
|
||||
if(nControl->idlecb && FtpLastError() == ERRPENDING) {
|
||||
while(!FtpCheckWrite(sData, &nControl->idletime)) {
|
||||
if(!nControl->idlecb(nControl, -2, nControl->idlearg)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue