*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include "glib-compat-private.h"
#include "gst_private.h"
+#include "glib-compat-private.h"
#include "gstdatetime.h"
#include "gstvalue.h"
#include <glib.h>
*
* Free-function: gst_date_time_unref
*
- * Returns: (transfer full): a newly created #GstDateTime, or NULL on error
+ * Returns: (transfer full): a newly created #GstDateTime, or %NULL on error
*/
GstDateTime *
gst_date_time_new_from_g_date_time (GDateTime * dt)
*
* Free-function: g_date_time_unref
*
- * Returns: (transfer full): a newly created #GDateTime, or NULL on error
+ * Returns: (transfer full): a newly created #GDateTime, or %NULL on error
*/
GDateTime *
gst_date_time_to_g_date_time (GstDateTime * datetime)
* gst_date_time_has_year:
* @datetime: a #GstDateTime
*
- * Returns: TRUE if @datetime<!-- -->'s year field is set (which should always
- * be the case), otherwise FALSE
+ * Returns: %TRUE if @datetime<!-- -->'s year field is set (which should always
+ * be the case), otherwise %FALSE
*/
gboolean
gst_date_time_has_year (const GstDateTime * datetime)
* gst_date_time_has_month:
* @datetime: a #GstDateTime
*
- * Returns: TRUE if @datetime<!-- -->'s month field is set, otherwise FALSE
+ * Returns: %TRUE if @datetime<!-- -->'s month field is set, otherwise %FALSE
*/
gboolean
gst_date_time_has_month (const GstDateTime * datetime)
* gst_date_time_has_day:
* @datetime: a #GstDateTime
*
- * Returns: TRUE if @datetime<!-- -->'s day field is set, otherwise FALSE
+ * Returns: %TRUE if @datetime<!-- -->'s day field is set, otherwise %FALSE
*/
gboolean
gst_date_time_has_day (const GstDateTime * datetime)
* gst_date_time_has_time:
* @datetime: a #GstDateTime
*
- * Returns: TRUE if @datetime<!-- -->'s hour and minute fields are set,
- * otherwise FALSE
+ * Returns: %TRUE if @datetime<!-- -->'s hour and minute fields are set,
+ * otherwise %FALSE
*/
gboolean
gst_date_time_has_time (const GstDateTime * datetime)
* gst_date_time_has_second:
* @datetime: a #GstDateTime
*
- * Returns: TRUE if @datetime<!-- -->'s second field is set, otherwise FALSE
+ * Returns: %TRUE if @datetime<!-- -->'s second field is set, otherwise %FALSE
*/
gboolean
gst_date_time_has_second (const GstDateTime * datetime)
*
* Note that @tzoffset is a float and was chosen so for being able to handle
* some fractional timezones, while it still keeps the readability of
- * represeting it in hours for most timezones.
+ * representing it in hours for most timezones.
*
* If value is -1 then all over value will be ignored. For example
* if @month == -1, then #GstDateTime will created only for @year. If
* 2012-06-23T23:30+0100, 2012-06-23T23:30:59Z, 2012-06-23T23:30:59+0100
*
* Returns: a newly allocated string formatted according to ISO 8601 and
- * only including the datetime fields that are valid, or NULL in case
+ * only including the datetime fields that are valid, or %NULL in case
* there was an error. The string should be freed with g_free().
*/
gchar *
*
* Free-function: gst_date_time_unref
*
- * Returns: (transfer full): a newly created #GstDateTime, or NULL on error
+ * Returns: (transfer full): a newly created #GstDateTime, or %NULL on error
*/
GstDateTime *
gst_date_time_new_from_iso8601_string (const gchar * string)
guint64 usecs;
gint len, ret;
- len = strlen (string);
+ g_return_val_if_fail (string != NULL, NULL);
- g_return_val_if_fail (len >= 4, NULL);
- g_return_val_if_fail (g_ascii_isdigit (*string), NULL);
+ GST_DEBUG ("Parsing '%s' into a datetime", string);
- GST_DEBUG ("Parsing %s into a datetime", string);
+ len = strlen (string);
+
+ if (len < 4 || !g_ascii_isdigit (string[0]) || !g_ascii_isdigit (string[1])
+ || !g_ascii_isdigit (string[2]) || !g_ascii_isdigit (string[3]))
+ return NULL;
ret = sscanf (string, "%04d-%02d-%02d", &year, &month, &day);