Author: wyoung
Date: Mon Jan 21 18:39:05 2008
New Revision: 2124
URL: http://svn.gna.org/viewcvs/mysqlpp?rev=2124&view=rev
Log:
- Added DateTime::now() static factory function, which just returns a
default DateTime instance, which is "NOW()". Syntactic sugar.
- Made "now" data member private and called it now_ as a consequence.
Outsiders shouldn't have access to this anyway; call is_now() instead.
Modified:
trunk/lib/datetime.cpp
trunk/lib/datetime.h
Modified: trunk/lib/datetime.cpp
URL:
http://svn.gna.org/viewcvs/mysqlpp/trunk/lib/datetime.cpp?rev=2124&r1=2123&r2=2124&view=diff
==============================================================================
--- trunk/lib/datetime.cpp (original)
+++ trunk/lib/datetime.cpp Mon Jan 21 18:39:05 2008
@@ -153,7 +153,7 @@
minute = t.minute;
second = t.second;
- now = false;
+ now_ = false;
return str;
}
@@ -239,14 +239,14 @@
minute = tm.tm_min;
second = tm.tm_sec;
- now = false;
+ now_ = false;
}
bool
DateTime::is_now() const
{
- return now &&
+ return now_ &&
year == 0 && month == 0 && day == 0 &&
hour == 0 && minute == 0 && second == 0;
}
Modified: trunk/lib/datetime.h
URL:
http://svn.gna.org/viewcvs/mysqlpp/trunk/lib/datetime.h?rev=2124&r1=2123&r2=2124&view=diff
==============================================================================
--- trunk/lib/datetime.h (original)
+++ trunk/lib/datetime.h Mon Jan 21 18:39:05 2008
@@ -117,7 +117,6 @@
unsigned char hour; ///< the hour, 0-23
unsigned char minute; ///< the minute, 0-59
unsigned char second; ///< the second, 0-59
- bool now; ///< true if not given explicit
value
/// \brief Default constructor
DateTime() :
@@ -128,7 +127,7 @@
hour(0),
minute(0),
second(0),
- now(true)
+ now_(true)
{
}
@@ -149,7 +148,7 @@
hour(h),
minute(min),
second(s),
- now(false)
+ now_(false)
{
}
@@ -162,7 +161,7 @@
hour(other.hour),
minute(other.minute),
second(other.second),
- now(false)
+ now_(other.now_)
{
}
@@ -209,8 +208,17 @@
/// values, but it's too simple a class to bother.
bool is_now() const;
+ /// \brief Factory to create an object instance that will convert
+ /// to SQL "NOW()" on insertion into a query
+ ///
+ /// This is just syntactic sugar around the default ctor
+ static DateTime now() { return DateTime(); }
+
/// Convert to time_t
operator time_t() const;
+
+private:
+ bool now_; ///< true if object not initialized with explicit value
};
_______________________________________________
Mysqlpp-commits mailing list
[email protected]
https://mail.gna.org/listinfo/mysqlpp-commits