glibmm r661 - in trunk: . glib/src tests tests/glibmm_date
- From: jaalburqu svn gnome org
- To: svn-commits-list gnome org
- Subject: glibmm r661 - in trunk: . glib/src tests tests/glibmm_date
- Date: Tue, 10 Jun 2008 20:32:02 +0000 (UTC)
Author: jaalburqu
Date: Tue Jun 10 20:32:02 2008
New Revision: 661
URL: http://svn.gnome.org/viewvc/glibmm?rev=661&view=rev
Log:
2008-06-09 Josà Alburquerque <jaalburqu svn gnome org>
* glib/src/date.ccg:
* glib/src/date.hg: Added copy constructor and assignment operator;
Made GDate constructor visible.
* configure.in:
* tests/Makefile.am:
* tests/glibmm_date/Makefile.am:
* tests/glibmm_date/main.cc: Added simple test to test Glib::Date.
Added:
trunk/tests/glibmm_date/
trunk/tests/glibmm_date/Makefile.am
trunk/tests/glibmm_date/main.cc
Modified:
trunk/ChangeLog
trunk/configure.in
trunk/glib/src/date.ccg
trunk/glib/src/date.hg
trunk/tests/Makefile.am
Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in (original)
+++ trunk/configure.in Tue Jun 10 20:32:02 2008
@@ -303,6 +303,7 @@
tests/Makefile
tests/glibmm_value/Makefile
tests/giomm_simple/Makefile
+ tests/glibmm_date/Makefile
examples/Makefile
examples/compose/Makefile
Modified: trunk/glib/src/date.ccg
==============================================================================
--- trunk/glib/src/date.ccg (original)
+++ trunk/glib/src/date.ccg Tue Jun 10 20:32:02 2008
@@ -58,6 +58,20 @@
gobject_ (castitem)
{}
+Date::Date(const Date& other)
+{
+ g_date_clear(&gobject_, 1);
+ g_date_set_julian(&gobject_, other.get_julian());
+}
+
+Date& Date::operator=(const Date& other)
+{
+ if (&other != this)
+ g_date_set_julian(&gobject_, other.get_julian());
+
+ return *this;
+}
+
void Date::clear()
{
g_date_clear(&gobject_, 1);
Modified: trunk/glib/src/date.hg
==============================================================================
--- trunk/glib/src/date.hg (original)
+++ trunk/glib/src/date.hg Tue Jun 10 20:32:02 2008
@@ -51,18 +51,57 @@
static const Year BAD_YEAR = 0;
static const guint32 BAD_JULIAN = 0;
+ /** Construct an undefined date.
+ */
Date();
+
+ /** Construct a date with given day, month and year.
+ * @param day The day.
+ * @param month The month.
+ * @param year The year.
+ */
Date(Day day, Month month, Year year);
+
+ /** Construct a date from a julian day.
+ * @param julian_day The julian day (guint32).
+ */
explicit Date(guint32 julian_day);
-#ifndef DOXYGEN_SHOULD_SKIP_THIS
+ /** Construct a Glib::Date from a GDate. The GDate is kept by Glib::Date and
+ * then destroyed when Glib::Date is destroyed.
+ * @param castitem The GDate.
+ */
explicit Date(const GDate& castitem);
-#endif
- void clear();
- /** Clear the date. The cleared dates will not represent an existing date, but will not contain garbage.
- * @param month Month to set.
+ /** Construct a Glib::Date from another.
+ * @param other the other Glib::Date.
+ */
+ Date(const Date& other);
+
+ /** Assign another date to this one. For example:
+ * @code
+ * ...
+ * Glib::Date my_date;
+ * my_date = other_date;
+ * @endcode
+ * @param other The other Glib::Date.
*/
+ Date& operator=(const Date& other);
+
+ /// Provides access to the underlying C instance.
+ GDate* gobj() { return &gobject_; }
+
+ /// Provides access to the underlying C instance.
+ const GDate* gobj() const { return &gobject_; }
+
+private:
+ GDate gobject_;
+
+public:
+ /** Clear the date. The cleared dates will not represent an existing date,
+ * but will not contain garbage.
+ */
+ void clear();
/** Parses a user-inputted string str, and try to figure out what date it represents, taking the current locale into account. If the string is successfully parsed, the date will be valid after the call. Otherwise, it will be invalid.
* This function is not appropriate for file formats and the like; it isn't very precise, and its exact behavior varies with the locale. It's intended to be a heuristic routine that guesses what the user means by a given string (and it does work pretty well in that capacity).
@@ -110,6 +149,8 @@
*/
void set_time(const GTimeVal& timeval);
+ /** Set Glib::Date to current time.
+ */
void set_time_current();
/** Sets the month of the year. If the resulting day-month-year triplet is invalid, the date will be invalid.
@@ -369,14 +410,6 @@
* @return true if the date is a valid one.
*/
static bool valid_dmy(Day day, Month month, Year year);
-
-#ifndef DOXYGEN_SHOULD_SKIP_THIS
- GDate* gobj() { return &gobject_; }
- const GDate* gobj() const { return &gobject_; }
-#endif
-
-private:
- GDate gobject_;
};
Modified: trunk/tests/Makefile.am
==============================================================================
--- trunk/tests/Makefile.am (original)
+++ trunk/tests/Makefile.am Tue Jun 10 20:32:02 2008
@@ -1,4 +1,4 @@
-test_dirs = glibmm_value giomm_simple
+test_dirs = glibmm_value giomm_simple glibmm_date
SUBDIRS = $(test_dirs)
EXTRA_DIST = Makefile.am_fragment
Added: trunk/tests/glibmm_date/Makefile.am
==============================================================================
--- (empty file)
+++ trunk/tests/glibmm_date/Makefile.am Tue Jun 10 20:32:02 2008
@@ -0,0 +1,14 @@
+include $(top_srcdir)/tests/Makefile.am_fragment
+
+noinst_PROGRAMS = test
+test_SOURCES = main.cc
+
+
+
+include $(top_srcdir)/tests/Makefile.am_fragment
+
+noinst_PROGRAMS = test
+test_SOURCES = main.cc
+
+
+
Added: trunk/tests/glibmm_date/main.cc
==============================================================================
--- (empty file)
+++ trunk/tests/glibmm_date/main.cc Tue Jun 10 20:32:02 2008
@@ -0,0 +1,56 @@
+#include <glibmm.h>
+#include <iostream>
+
+int main(int, char**)
+{
+ Glib::Date date;
+ date.set_time_current();
+ date.add_months(1);
+ date.subtract_days(1);
+ date.add_years(1);
+
+ std::cout << "The date a year and a month from yesterday will be: " <<
+ date.get_month() << "/" << (int) date.get_day() << "/" << date.get_year() <<
+ "." << std::endl;
+
+
+ Glib::Date copy_date(date);
+ Glib::Date assigned_date;
+
+ assigned_date = copy_date;
+
+ std::cout << "The copied date is: " << copy_date.get_month() << "/" <<
+ (int) copy_date.get_day() << "/" << copy_date.get_year() << "." <<
+ std::endl;
+
+ return 0;
+}
+
+#include <glibmm.h>
+#include <iostream>
+
+int main(int, char**)
+{
+ Glib::Date date;
+ date.set_time_current();
+ date.add_months(1);
+ date.subtract_days(1);
+ date.add_years(1);
+
+ std::cout << "The date a year and a month from yesterday will be: " <<
+ date.get_month() << "/" << (int) date.get_day() << "/" << date.get_year() <<
+ "." << std::endl;
+
+
+ Glib::Date copy_date(date);
+ Glib::Date assigned_date;
+
+ assigned_date = copy_date;
+
+ std::cout << "The copied date is: " << copy_date.get_month() << "/" <<
+ (int) copy_date.get_day() << "/" << copy_date.get_year() << "." <<
+ std::endl;
+
+ return 0;
+}
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]