mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-08-21 22:04:56 -06:00
Core: ConvertDate::Truncate, StdConvertDateTruncate
git-svn-id: svn://ultimatepp.org/upp/trunk@2048 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
5d96d8cf79
commit
626d569bf6
2 changed files with 25 additions and 1 deletions
|
|
@ -382,12 +382,21 @@ ConvertDouble::~ConvertDouble() {}
|
|||
ConvertDate::ConvertDate(Date minval, Date maxval, bool notnull)
|
||||
: minval(minval), maxval(maxval), notnull(notnull) {
|
||||
defaultval = Null;
|
||||
truncate = false;
|
||||
}
|
||||
|
||||
ConvertDate::~ConvertDate()
|
||||
{
|
||||
}
|
||||
|
||||
Value ConvertDate::Format(const Value& q) const
|
||||
{
|
||||
if(truncate && IsDateTime(q))
|
||||
return Convert::Format((Date)q);
|
||||
return Convert::Format(q);
|
||||
}
|
||||
|
||||
|
||||
Value ConvertDate::Scan(const Value& text) const {
|
||||
Value v = UPP::Scan(DATE_V, text, defaultval);
|
||||
if(IsError(v)) return v;
|
||||
|
|
@ -473,6 +482,17 @@ GLOBAL_VARP_INIT(const ConvertTime, StdConvertTimeNotNull, (Null, Null, true))
|
|||
GLOBAL_VAR_INIT(const ConvertString, StdConvertString);
|
||||
GLOBAL_VARP_INIT(const ConvertString, StdConvertStringNotNull, (INT_MAX, true))
|
||||
|
||||
const ConvertDate& StdConvertDateTruncated()
|
||||
{
|
||||
static ConvertDate *cv;
|
||||
ONCELOCK {
|
||||
static ConvertDate cvd;
|
||||
cvd.Truncate();
|
||||
cv = &cvd;
|
||||
}
|
||||
return *cv;
|
||||
}
|
||||
|
||||
Value MapConvert::Format(const Value& q) const {
|
||||
return map.Get(q, Null);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -124,12 +124,13 @@ const ConvertDouble& StdConvertDoubleNotNull();
|
|||
|
||||
class ConvertDate : public Convert {
|
||||
public:
|
||||
virtual Value Format(const Value& q) const;
|
||||
virtual Value Scan(const Value& text) const;
|
||||
virtual int Filter(int chr) const;
|
||||
|
||||
protected:
|
||||
Date minval, maxval, defaultval;
|
||||
bool notnull;
|
||||
bool notnull, truncate;
|
||||
|
||||
public:
|
||||
ConvertDate& MinMax(Date _min, Date _max) { minval = _min; maxval = _max; return *this; }
|
||||
|
|
@ -137,16 +138,19 @@ public:
|
|||
ConvertDate& Max(Date _max) { maxval = _max; return *this; }
|
||||
ConvertDate& NotNull(bool b = true) { notnull = b; return *this; }
|
||||
ConvertDate& NoNotNull() { return NotNull(false); }
|
||||
ConvertDate& Truncate(bool b = true) { truncate = b; return *this; }
|
||||
ConvertDate& Default(Date d) { defaultval = d; return *this; }
|
||||
Date GetMin() const { return minval; }
|
||||
Date GetMax() const { return maxval; }
|
||||
bool IsNotNull() const { return notnull; }
|
||||
|
||||
|
||||
ConvertDate(Date minval = Date::Low(), Date maxval = Date::High(), bool notnull = false);
|
||||
virtual ~ConvertDate();
|
||||
};
|
||||
|
||||
const ConvertDate& StdConvertDate();
|
||||
const ConvertDate& StdConvertDateTruncated();
|
||||
const ConvertDate& StdConvertDateNotNull();
|
||||
|
||||
class ConvertTime : public Convert {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue