[glibmm] Wrapped several ISO 8601 related functions.



commit ea7aab45922a6756ebd305499c1131d5fc1efb5b
Author: Krzesimir Nowak <krnowak svn gnome org>
Date:   Sat Jul 18 14:35:43 2009 +0200

    Wrapped several ISO 8601 related functions.
    
    * glib/glibmm/timeval.cc:
    * glib/glibmm/timeval.h: Wrapped g_time_val_from_iso8601() and
    g_time_val_to_iso8601().
    * glib/src/date.ccg:
    * glib/src/date.hg: Wrapped g_date_get_iso8601_week_of_year().

 ChangeLog              |    9 +++++++++
 glib/glibmm/timeval.cc |   17 +++++++++++++++++
 glib/glibmm/timeval.h  |   17 +++++++++++++++++
 glib/src/date.ccg      |    5 +++++
 glib/src/date.hg       |    8 ++++++++
 5 files changed, 56 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 5631a40..70d1b24 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2009-07-26  Krzesimir Nowak  <krnowak svn gnome org>
+
+	* glib/glibmm/timeval.cc:
+	* glib/glibmm/timeval.h: Wrapped g_time_val_from_iso8601()
+	and g_time_val_to_iso8601().
+	* glib/src/date.ccg:
+	* glib/src/date.hg: Wrapped
+	g_date_get_iso8601_week_of_year().
+	
 2009-07-17  David King  <davidk openismus com>
 
 	* examples/properties/properties_example.cc: Only compile the
diff --git a/glib/glibmm/timeval.cc b/glib/glibmm/timeval.cc
index 7bb445e..f99083b 100644
--- a/glib/glibmm/timeval.cc
+++ b/glib/glibmm/timeval.cc
@@ -30,6 +30,11 @@ void TimeVal::assign_current_time()
 {
   g_get_current_time(this);
 }
+ 
+bool TimeVal::assign_from_iso8601(const Glib::ustring& iso_date)
+{
+  return g_time_val_from_iso8601(iso_date.c_str(), this);
+}
 
 void TimeVal::add(const TimeVal& rhs)
 {
@@ -112,5 +117,17 @@ void TimeVal::subtract_microseconds(long microseconds)
   g_time_val_add(this, -1 * microseconds);
 }
 
+Glib::ustring TimeVal::as_iso8601() const
+{
+  gchar *retval = g_time_val_to_iso8601(const_cast<Glib::TimeVal*>(this));
+  if (retval)
+  {
+    Glib::ustring iso_date(retval);
+    g_free(retval);
+    return iso_date;
+  }
+  return Glib::ustring();
+}
+
 } // namespace Glib
 
diff --git a/glib/glibmm/timeval.h b/glib/glibmm/timeval.h
index c22af8b..7e49652 100644
--- a/glib/glibmm/timeval.h
+++ b/glib/glibmm/timeval.h
@@ -24,6 +24,7 @@
  */
 
 #include <glib.h>
+#include <glibmm/ustring.h>
 
 namespace Glib
 {
@@ -46,6 +47,15 @@ struct TimeVal : public GTimeVal
    * works also on Win32. 
    */
   void assign_current_time();
+  
+  /** Converts a string containing an ISO 8601 encoded date and time
+   * to a Glib::TimeVal and puts it in TimeVal instance.
+   * @param iso_date ISO 8601 encoded string.
+   * @return <tt>true</tt> if conversion was successful.
+   *
+   * @newin2p22
+   */
+  bool assign_from_iso8601(const Glib::ustring& iso_date);
 
   void add(const TimeVal& rhs);
   void subtract(const TimeVal& rhs);
@@ -68,6 +78,13 @@ struct TimeVal : public GTimeVal
    */
   inline double as_double() const;
 
+  /** Returns an ISO 8601 encoded string, relative to the Coordinated
+   * Universal Time (UTC).
+   *
+   * @newin2p22
+   */
+  Glib::ustring as_iso8601() const;
+
   inline bool negative() const;
 
   /** Checks whether the stored time interval is positive.
diff --git a/glib/src/date.ccg b/glib/src/date.ccg
index 3bd6697..e7c3dbc 100644
--- a/glib/src/date.ccg
+++ b/glib/src/date.ccg
@@ -265,6 +265,11 @@ unsigned int Date::get_sunday_week_of_year() const
   return g_date_get_sunday_week_of_year(&gobject_);
 }
 
+unsigned int Date::get_iso8601_week_of_year() const
+{
+  return g_date_get_iso8601_week_of_year(&gobject_);
+}
+
 bool Date::is_first_of_month() const
 {
   return g_date_is_first_of_month(&gobject_);
diff --git a/glib/src/date.hg b/glib/src/date.hg
index 47606c3..a0587c8 100644
--- a/glib/src/date.hg
+++ b/glib/src/date.hg
@@ -314,6 +314,14 @@ public:
    */
   unsigned int get_sunday_week_of_year() const;
 
+  /** Returns the week of the year, where weeks are interpreted according to ISO 8601.
+   * The date must be valid.
+   * @return ISO 8601 week number of the year.
+   *
+   * @newin2p22
+   */
+  unsigned int get_iso8601_week_of_year() const;
+
   /** Returns true if the date is on the first of a month. 
    * The date must be valid.
    * @return true if the date is the first of the month. 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]