[libsoup/wip/remove-deprecations] Replace SoupDate with GDateTime




commit 43828ff353205353b77d186eb751a546cb4e4fa1
Author: Patrick Griffis <pgriffis igalia com>
Date:   Fri Aug 28 17:16:15 2020 -0500

    Replace SoupDate with GDateTime

 docs/reference/libsoup-2.4-sections.txt |  22 +-
 libsoup/cache/soup-cache.c              |  30 +-
 libsoup/cookies/soup-cookie-jar-db.c    |   2 +-
 libsoup/cookies/soup-cookie-jar-text.c  |   2 +-
 libsoup/cookies/soup-cookie-jar.c       |   7 +-
 libsoup/cookies/soup-cookie.c           |  38 +-
 libsoup/cookies/soup-cookie.h           |  18 +-
 libsoup/hsts/soup-hsts-enforcer-db.c    |   8 +-
 libsoup/hsts/soup-hsts-policy.c         |  25 +-
 libsoup/hsts/soup-hsts-policy.h         |   4 +-
 libsoup/include/soup-installed.h        |   2 +-
 libsoup/meson.build                     |   4 +-
 libsoup/soup-date-utils-private.h       |  30 ++
 libsoup/soup-date-utils.c               | 323 +++++++++++
 libsoup/soup-date-utils.h               |  38 ++
 libsoup/soup-date.c                     | 911 --------------------------------
 libsoup/soup-date.h                     |  88 ---
 libsoup/soup-server.c                   |   8 +-
 libsoup/soup-types.h                    |   1 -
 libsoup/soup.h                          |   2 +-
 tests/cache-test.c                      |  17 +-
 tests/date-test.c                       | 177 ++-----
 22 files changed, 515 insertions(+), 1242 deletions(-)
---
diff --git a/docs/reference/libsoup-2.4-sections.txt b/docs/reference/libsoup-2.4-sections.txt
index 9c8043a8..b258c9ae 100644
--- a/docs/reference/libsoup-2.4-sections.txt
+++ b/docs/reference/libsoup-2.4-sections.txt
@@ -593,24 +593,9 @@ soup_uri_get_type
 <SECTION>
 <FILE>soup-misc</FILE>
 <TITLE>Soup Miscellaneous Utilities</TITLE>
-SoupDate
 SoupDateFormat
-soup_date_new
-soup_date_new_from_string
-soup_date_new_from_time_t
-soup_date_new_from_now
-soup_date_to_string
-soup_date_to_time_t
-soup_date_is_past
-soup_date_get_day
-soup_date_get_hour
-soup_date_get_minute
-soup_date_get_month
-soup_date_get_offset
-soup_date_get_second
-soup_date_get_utc
-soup_date_get_year
-soup_date_free
+soup_date_time_new_from_http_string
+soup_date_time_to_string
 <SUBSECTION>
 soup_headers_parse_request
 soup_headers_parse_response
@@ -637,9 +622,6 @@ soup_add_idle
 soup_add_io_watch
 soup_add_timeout
 <SUBSECTION Private>
-soup_date_copy
-SOUP_TYPE_DATE
-soup_date_get_type
 soup_char_is_token
 soup_char_is_uri_gen_delims
 soup_char_is_uri_percent_encoded
diff --git a/libsoup/cache/soup-cache.c b/libsoup/cache/soup-cache.c
index 09c71a44..ae79d793 100644
--- a/libsoup/cache/soup-cache.c
+++ b/libsoup/cache/soup-cache.c
@@ -390,18 +390,18 @@ soup_cache_entry_set_freshness (SoupCacheEntry *entry, SoupMessage *msg, SoupCac
        expires = soup_message_headers_get_one (entry->headers, "Expires");
        date = soup_message_headers_get_one (entry->headers, "Date");
        if (expires && date) {
-               SoupDate *expires_d, *date_d;
+               GDateTime *expires_d, *date_d;
                time_t expires_t, date_t;
 
-               expires_d = soup_date_new_from_string (expires);
+               expires_d = soup_date_time_new_from_http_string (expires);
                if (expires_d) {
-                       date_d = soup_date_new_from_string (date);
+                       date_d = soup_date_time_new_from_http_string (date);
 
-                       expires_t = soup_date_to_time_t (expires_d);
-                       date_t = soup_date_to_time_t (date_d);
+                       expires_t = g_date_time_to_unix (expires_d);
+                       date_t = g_date_time_to_unix (date_d);
 
-                       soup_date_free (expires_d);
-                       soup_date_free (date_d);
+                       g_date_time_unref (expires_d);
+                       g_date_time_unref (date_d);
 
                        if (expires_t && date_t) {
                                entry->freshness_lifetime = (guint32) MAX (expires_t - date_t, 0);
@@ -434,17 +434,17 @@ soup_cache_entry_set_freshness (SoupCacheEntry *entry, SoupMessage *msg, SoupCac
        /* Last-Modified based heuristic */
        last_modified = soup_message_headers_get_one (entry->headers, "Last-Modified");
        if (last_modified) {
-               SoupDate *soup_date;
+               GDateTime *soup_date;
                time_t now, last_modified_t;
 
-               soup_date = soup_date_new_from_string (last_modified);
-               last_modified_t = soup_date_to_time_t (soup_date);
+               soup_date = soup_date_time_new_from_http_string (last_modified);
+               last_modified_t = g_date_time_to_unix (soup_date);
                now = time (NULL);
 
 #define HEURISTIC_FACTOR 0.1 /* From Section 2.3.1.1 */
 
                entry->freshness_lifetime = MAX (0, (now - last_modified_t) * HEURISTIC_FACTOR);
-               soup_date_free (soup_date);
+               g_date_time_unref (soup_date);
        }
 
        return;
@@ -481,13 +481,13 @@ soup_cache_entry_new (SoupCache *cache, SoupMessage *msg, time_t request_time, t
        date = soup_message_headers_get_one (entry->headers, "Date");
 
        if (date) {
-               SoupDate *soup_date;
+               GDateTime *soup_date;
                const char *age;
                time_t date_value, apparent_age, corrected_received_age, response_delay, age_value = 0;
 
-               soup_date = soup_date_new_from_string (date);
-               date_value = soup_date_to_time_t (soup_date);
-               soup_date_free (soup_date);
+               soup_date = soup_date_time_new_from_http_string (date);
+               date_value = g_date_time_to_unix (soup_date);
+               g_date_time_unref (soup_date);
 
                age = soup_message_headers_get_one (entry->headers, "Age");
                if (age)
diff --git a/libsoup/cookies/soup-cookie-jar-db.c b/libsoup/cookies/soup-cookie-jar-db.c
index c6f698d4..7ee9123f 100644
--- a/libsoup/cookies/soup-cookie-jar-db.c
+++ b/libsoup/cookies/soup-cookie-jar-db.c
@@ -297,7 +297,7 @@ soup_cookie_jar_db_changed (SoupCookieJar *jar,
        if (new_cookie && new_cookie->expires) {
                gulong expires;
                
-               expires = (gulong)soup_date_to_time_t (new_cookie->expires);
+               expires = (gulong)g_date_time_to_unix (new_cookie->expires);
                query = sqlite3_mprintf (QUERY_INSERT, 
                                         new_cookie->name,
                                         new_cookie->value,
diff --git a/libsoup/cookies/soup-cookie-jar-text.c b/libsoup/cookies/soup-cookie-jar-text.c
index 31c0d891..7a57494d 100644
--- a/libsoup/cookies/soup-cookie-jar-text.c
+++ b/libsoup/cookies/soup-cookie-jar-text.c
@@ -267,7 +267,7 @@ write_cookie (FILE *out, SoupCookie *cookie)
                 *cookie->domain == '.' ? "TRUE" : "FALSE",
                 cookie->path,
                 cookie->secure ? "TRUE" : "FALSE",
-                (gulong)soup_date_to_time_t (cookie->expires),
+                (gulong)g_date_time_to_unix (cookie->expires),
                 cookie->name,
                 cookie->value,
                 same_site_policy_to_string (soup_cookie_get_same_site_policy (cookie)));
diff --git a/libsoup/cookies/soup-cookie-jar.c b/libsoup/cookies/soup-cookie-jar.c
index f2433384..1cf24f3a 100644
--- a/libsoup/cookies/soup-cookie-jar.c
+++ b/libsoup/cookies/soup-cookie-jar.c
@@ -12,6 +12,7 @@
 #include <string.h>
 
 #include "soup-cookie-jar.h"
+#include "soup-date-utils-private.h"
 #include "soup-message-private.h"
 #include "soup-misc.h"
 #include "soup.h"
@@ -343,7 +344,7 @@ get_cookies (SoupCookieJar *jar,
                        GSList *next = domain_cookies->next;
                        SoupCookie *cookie = domain_cookies->data;
 
-                       if (cookie->expires && soup_date_is_past (cookie->expires)) {
+                       if (cookie->expires && soup_date_time_is_past (cookie->expires)) {
                                cookies_to_remove = g_slist_append (cookies_to_remove,
                                                                    cookie);
                                new_head = g_slist_delete_link (new_head, domain_cookies);
@@ -610,7 +611,7 @@ soup_cookie_jar_add_cookie_full (SoupCookieJar *jar, SoupCookie *cookie, SoupURI
                                 * https://tools.ietf.org/html/draft-ietf-httpbis-cookie-alone-01
                                 */
                                soup_cookie_free (cookie);
-                       } else if (cookie->expires && soup_date_is_past (cookie->expires)) {
+                       } else if (cookie->expires && soup_date_time_is_past (cookie->expires)) {
                                /* The new cookie has an expired date,
                                 * this is the way the the server has
                                 * of telling us that we have to
@@ -635,7 +636,7 @@ soup_cookie_jar_add_cookie_full (SoupCookieJar *jar, SoupCookie *cookie, SoupURI
        }
 
        /* The new cookie is... a new cookie */
-       if (cookie->expires && soup_date_is_past (cookie->expires)) {
+       if (cookie->expires && soup_date_time_is_past (cookie->expires)) {
                soup_cookie_free (cookie);
                return;
        }
diff --git a/libsoup/cookies/soup-cookie.c b/libsoup/cookies/soup-cookie.c
index 5fa4c251..71540bd8 100644
--- a/libsoup/cookies/soup-cookie.c
+++ b/libsoup/cookies/soup-cookie.c
@@ -13,6 +13,7 @@
 #include <string.h>
 
 #include "soup-cookie.h"
+#include "soup-date-utils-private.h"
 #include "soup-misc.h"
 #include "soup.h"
 
@@ -85,7 +86,7 @@ soup_cookie_copy (SoupCookie *cookie)
        copy->domain = g_strdup (cookie->domain);
        copy->path = g_strdup (cookie->path);
        if (cookie->expires)
-               copy->expires = soup_date_copy(cookie->expires);
+               copy->expires = g_date_time_ref (cookie->expires);
        copy->secure = cookie->secure;
        copy->http_only = cookie->http_only;
        soup_cookie_set_same_site_policy (copy, soup_cookie_get_same_site_policy (cookie));
@@ -157,14 +158,14 @@ parse_value (const char **val_p, gboolean copy)
        return value;
 }
 
-static SoupDate *
+static GDateTime *
 parse_date (const char **val_p)
 {
        char *value;
-       SoupDate *date;
+       GDateTime *date;
 
        value = parse_value (val_p, TRUE);
-       date = soup_date_new_from_string (value);
+       date = soup_date_time_new_from_http_string (value);
        g_free (value);
        return date;
 }
@@ -563,7 +564,7 @@ void
 soup_cookie_set_max_age (SoupCookie *cookie, int max_age)
 {
        if (cookie->expires)
-               soup_date_free (cookie->expires);
+               g_date_time_unref (cookie->expires);
 
        if (max_age == -1)
                cookie->expires = NULL;
@@ -571,9 +572,12 @@ soup_cookie_set_max_age (SoupCookie *cookie, int max_age)
                /* Use a date way in the past, to protect against
                 * clock skew.
                 */
-               cookie->expires = soup_date_new (1970, 1, 1, 0, 0, 0);
-       } else
-               cookie->expires = soup_date_new_from_now (max_age);
+               cookie->expires = g_date_time_new_from_unix_utc (0);
+       } else {
+                GDateTime *now = g_date_time_new_now_utc ();
+                cookie->expires = g_date_time_add_seconds (now, max_age);
+                g_date_time_unref (now);
+        }
 }
 
 /**
@@ -611,7 +615,7 @@ soup_cookie_set_max_age (SoupCookie *cookie, int max_age)
 
 /**
  * soup_cookie_get_expires:
- * @cookie: a #SoupCookie
+ * @cookie: a #GDateTime
  *
  * Gets @cookie's expiration time.
  *
@@ -621,7 +625,7 @@ soup_cookie_set_max_age (SoupCookie *cookie, int max_age)
  *
  * Since: 2.32
  **/
-SoupDate *
+GDateTime *
 soup_cookie_get_expires (SoupCookie *cookie)
 {
        return cookie->expires;
@@ -641,13 +645,13 @@ soup_cookie_get_expires (SoupCookie *cookie)
  * Since: 2.24
  **/
 void
-soup_cookie_set_expires (SoupCookie *cookie, SoupDate *expires)
+soup_cookie_set_expires (SoupCookie *cookie, GDateTime *expires)
 {
        if (cookie->expires)
-               soup_date_free (cookie->expires);
+               g_date_time_unref (cookie->expires);
 
        if (expires)
-               cookie->expires = soup_date_copy (expires);
+               cookie->expires = g_date_time_ref (expires);
        else
                cookie->expires = NULL;
 }
@@ -745,8 +749,8 @@ serialize_cookie (SoupCookie *cookie, GString *header, gboolean set_cookie)
                char *timestamp;
 
                g_string_append (header, "; expires=");
-               timestamp = soup_date_to_string (cookie->expires,
-                                                SOUP_DATE_COOKIE);
+               timestamp = soup_date_time_to_string (cookie->expires,
+                                                     SOUP_DATE_COOKIE);
                g_string_append (header, timestamp);
                g_free (timestamp);
        }
@@ -872,7 +876,7 @@ soup_cookie_free (SoupCookie *cookie)
        g_free (cookie->value);
        g_free (cookie->domain);
        g_free (cookie->path);
-       g_clear_pointer (&cookie->expires, soup_date_free);
+       g_clear_pointer (&cookie->expires, g_date_time_unref);
 
        g_dataset_destroy (cookie);
        g_slice_free (SoupCookie, cookie);
@@ -1085,7 +1089,7 @@ soup_cookie_applies_to_uri (SoupCookie *cookie, SoupURI *uri)
        if (cookie->secure && !soup_uri_is_https (uri, NULL))
                return FALSE;
 
-       if (cookie->expires && soup_date_is_past (cookie->expires))
+       if (cookie->expires && soup_date_time_is_past (cookie->expires))
                return FALSE;
 
        /* uri->path is required to be non-NULL */
diff --git a/libsoup/cookies/soup-cookie.h b/libsoup/cookies/soup-cookie.h
index eb533a55..7f514d1f 100644
--- a/libsoup/cookies/soup-cookie.h
+++ b/libsoup/cookies/soup-cookie.h
@@ -24,13 +24,13 @@ typedef enum {
 } SoupSameSitePolicy;
 
 struct _SoupCookie {
-       char     *name;
-       char     *value;
-       char     *domain;
-       char     *path;
-       SoupDate *expires;
-       gboolean  secure;
-       gboolean  http_only;
+       char      *name;
+       char      *value;
+       char      *domain;
+       char      *path;
+       GDateTime *expires;
+       gboolean   secure;
+       gboolean   http_only;
 };
 
 SOUP_AVAILABLE_IN_2_24
@@ -78,10 +78,10 @@ SOUP_AVAILABLE_IN_2_24
 void        soup_cookie_set_max_age             (SoupCookie  *cookie,
                                                 int          max_age);
 SOUP_AVAILABLE_IN_2_32
-SoupDate   *soup_cookie_get_expires             (SoupCookie  *cookie);
+GDateTime   *soup_cookie_get_expires            (SoupCookie  *cookie);
 SOUP_AVAILABLE_IN_2_24
 void        soup_cookie_set_expires             (SoupCookie  *cookie,
-                                                SoupDate    *expires);
+                                                GDateTime    *expires);
 SOUP_AVAILABLE_IN_2_32
 gboolean    soup_cookie_get_secure              (SoupCookie  *cookie);
 SOUP_AVAILABLE_IN_2_24
diff --git a/libsoup/hsts/soup-hsts-enforcer-db.c b/libsoup/hsts/soup-hsts-enforcer-db.c
index 1caa46bf..fd1a6997 100644
--- a/libsoup/hsts/soup-hsts-enforcer-db.c
+++ b/libsoup/hsts/soup-hsts-enforcer-db.c
@@ -148,7 +148,7 @@ query_all_callback (void *data, int argc, char **argv, char **colname)
        gulong expire_time;
        unsigned long max_age;
        time_t now;
-       SoupDate *expires;
+       GDateTime *expires;
        gboolean include_subdomains = FALSE;
 
        now = time (NULL);
@@ -159,7 +159,7 @@ query_all_callback (void *data, int argc, char **argv, char **colname)
        if (now >= expire_time)
                return 0;
 
-       expires = soup_date_new_from_time_t (expire_time);
+       expires = g_date_time_new_from_unix_utc (expire_time);
        max_age = strtoul (argv[COL_MAX_AGE], NULL, 10);
        include_subdomains = (g_strcmp0 (argv[COL_SUBDOMAINS], "1") == 0);
 
@@ -169,7 +169,7 @@ query_all_callback (void *data, int argc, char **argv, char **colname)
                soup_hsts_enforcer_set_policy (hsts_enforcer, policy);
                soup_hsts_policy_free (policy);
        } else
-               soup_date_free (expires);
+               g_date_time_unref (expires);
 
        return 0;
 }
@@ -277,7 +277,7 @@ soup_hsts_enforcer_db_changed (SoupHSTSEnforcer *hsts_enforcer,
        if (new_policy && new_policy->expires) {
                gulong expires;
 
-               expires = (gulong)soup_date_to_time_t (new_policy->expires);
+               expires = (gulong)g_date_time_to_unix (new_policy->expires);
                query = sqlite3_mprintf (QUERY_INSERT,
                                         new_policy->domain,
                                         new_policy->domain,
diff --git a/libsoup/hsts/soup-hsts-policy.c b/libsoup/hsts/soup-hsts-policy.c
index 3158143a..39bce01d 100644
--- a/libsoup/hsts/soup-hsts-policy.c
+++ b/libsoup/hsts/soup-hsts-policy.c
@@ -15,6 +15,7 @@
 #include <string.h>
 
 #include "soup-hsts-policy.h"
+#include "soup-date-utils-private.h"
 #include "soup.h"
 
 /**
@@ -76,7 +77,7 @@ soup_hsts_policy_copy (SoupHSTSPolicy *policy)
        copy->domain = g_strdup (policy->domain);
        copy->max_age = policy->max_age;
        copy->expires = policy->expires ?
-               soup_date_copy (policy->expires) : NULL;
+               g_date_time_ref (policy->expires) : NULL;
        copy->include_subdomains = policy->include_subdomains;
 
        return copy;
@@ -113,8 +114,7 @@ soup_hsts_policy_equal (SoupHSTSPolicy *policy1, SoupHSTSPolicy *policy2)
                return FALSE;
 
        if (policy1->expires && policy2->expires &&
-           soup_date_to_time_t (policy1->expires) !=
-           soup_date_to_time_t (policy2->expires))
+           !g_date_time_equal (policy1->expires, policy2->expires))
                return FALSE;
 
        return TRUE;
@@ -158,15 +158,18 @@ soup_hsts_policy_new (const char *domain,
                      unsigned long max_age,
                      gboolean include_subdomains)
 {
-       SoupDate *expires;
+       GDateTime *expires;
 
        if (max_age == SOUP_HSTS_POLICY_MAX_AGE_PAST) {
                /* Use a date way in the past, to protect against
                 * clock skew.
                 */
-               expires = soup_date_new (1970, 1, 1, 0, 0, 0);
-       } else
-               expires = soup_date_new_from_now (max_age);
+                expires = g_date_time_new_from_unix_utc (0);
+       } else {
+                GDateTime *now = g_date_time_new_now_utc ();
+                expires = g_date_time_add_seconds (now, max_age);
+                g_date_time_unref (now);
+        }
 
        return soup_hsts_policy_new_full (domain, max_age, expires, include_subdomains);
 }
@@ -188,7 +191,7 @@ soup_hsts_policy_new (const char *domain,
 SoupHSTSPolicy *
 soup_hsts_policy_new_full (const char *domain,
                           unsigned long max_age,
-                          SoupDate *expires,
+                          GDateTime *expires,
                           gboolean include_subdomains)
 {
        SoupHSTSPolicy *policy;
@@ -208,7 +211,7 @@ soup_hsts_policy_new_full (const char *domain,
        }
 
        policy->max_age = max_age;
-       policy->expires = expires;
+       policy->expires = expires ? g_date_time_ref (expires) : NULL;
        policy->include_subdomains = include_subdomains;
 
        return policy;
@@ -345,7 +348,7 @@ soup_hsts_policy_is_expired (SoupHSTSPolicy *policy)
 {
        g_return_val_if_fail (policy != NULL, TRUE);
 
-       return policy->expires && soup_date_is_past (policy->expires);
+       return policy->expires && soup_date_time_is_past (policy->expires);
 }
 
 /**
@@ -399,6 +402,6 @@ soup_hsts_policy_free (SoupHSTSPolicy *policy)
        g_return_if_fail (policy != NULL);
 
        g_free (policy->domain);
-       g_clear_pointer (&policy->expires, soup_date_free);
+       g_clear_pointer (&policy->expires, g_date_time_unref);
        g_slice_free (SoupHSTSPolicy, policy);
 }
diff --git a/libsoup/hsts/soup-hsts-policy.h b/libsoup/hsts/soup-hsts-policy.h
index b55f496b..4879f282 100644
--- a/libsoup/hsts/soup-hsts-policy.h
+++ b/libsoup/hsts/soup-hsts-policy.h
@@ -13,7 +13,7 @@ G_BEGIN_DECLS
 struct _SoupHSTSPolicy {
        char                 *domain;
        unsigned long         max_age;
-       SoupDate             *expires;
+       GDateTime            *expires;
        gboolean              include_subdomains;
 };
 
@@ -30,7 +30,7 @@ SoupHSTSPolicy  *soup_hsts_policy_new                 (const char     *domain,
 SOUP_AVAILABLE_IN_2_68
 SoupHSTSPolicy  *soup_hsts_policy_new_full             (const char     *domain,
                                                         unsigned long   max_age,
-                                                        SoupDate       *expires,
+                                                        GDateTime      *expires,
                                                         gboolean        include_subdomains);
 SOUP_AVAILABLE_IN_2_68
 SoupHSTSPolicy  *soup_hsts_policy_new_session_policy   (const char     *domain,
diff --git a/libsoup/include/soup-installed.h b/libsoup/include/soup-installed.h
index c1e45b01..1abe966e 100644
--- a/libsoup/include/soup-installed.h
+++ b/libsoup/include/soup-installed.h
@@ -28,7 +28,7 @@ extern "C" {
 #include <libsoup/soup-cookie-jar.h>
 #include <libsoup/soup-cookie-jar-db.h>
 #include <libsoup/soup-cookie-jar-text.h>
-#include <libsoup/soup-date.h>
+#include <libsoup/soup-date-utils.h>
 #include <libsoup/soup-enum-types.h>
 #include <libsoup/soup-form.h>
 #include <libsoup/soup-headers.h>
diff --git a/libsoup/meson.build b/libsoup/meson.build
index 9ca423be..ec664559 100644
--- a/libsoup/meson.build
+++ b/libsoup/meson.build
@@ -50,7 +50,7 @@ soup_sources = [
   'soup-body-output-stream.c',
   'soup-client-input-stream.c',
   'soup-connection.c',
-  'soup-date.c',
+  'soup-date-utils.c',
   'soup-directory-input-stream.c',
   'soup-filter-input-stream.c',
   'soup-form.c',
@@ -122,7 +122,7 @@ soup_introspection_headers = [
   'websocket/soup-websocket-extension-deflate.h',
   'websocket/soup-websocket-extension-manager.h',
 
-  'soup-date.h',
+  'soup-date-utils.h',
   'soup-form.h',
   'soup-headers.h',
   'soup-logger.h',
diff --git a/libsoup/soup-date-utils-private.h b/libsoup/soup-date-utils-private.h
new file mode 100644
index 00000000..568b11a3
--- /dev/null
+++ b/libsoup/soup-date-utils-private.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2020 Igalia, S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#pragma once
+
+#include "soup-types.h"
+
+G_BEGIN_DECLS
+
+gboolean        soup_date_time_is_past          (GDateTime      *date);
+
+G_END_DECLS
+
+
diff --git a/libsoup/soup-date-utils.c b/libsoup/soup-date-utils.c
new file mode 100644
index 00000000..27d1ae73
--- /dev/null
+++ b/libsoup/soup-date-utils.c
@@ -0,0 +1,323 @@
+/*
+ * Copyright (C) 2020 Igalia, S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "soup-date-utils.h"
+#include "soup-date-utils-private.h"
+
+/**
+ * soup_date_time_is_past:
+ * @date: a #GDateTime
+ *
+ * Determines if @date is in the past.
+ *
+ * Return value: %TRUE if @date is in the past
+ */
+gboolean
+soup_date_time_is_past (GDateTime *date)
+{
+        g_return_val_if_fail (date != NULL, TRUE);
+
+       /* optimization */
+       if (g_date_time_get_year (date) < 2020)
+               return TRUE;
+
+       return g_date_time_to_unix (date) < time (NULL);
+}
+
+/**
+ * SoupDateFormat:
+ * @SOUP_DATE_HTTP: RFC 1123 format, used by the HTTP "Date" header. Eg
+ * "Sun, 06 Nov 1994 08:49:37 GMT"
+ * @SOUP_DATE_COOKIE: The format for the "Expires" timestamp in the
+ * Netscape cookie specification. Eg, "Sun, 06-Nov-1994 08:49:37 GMT".
+ *
+ * Date formats that soup_date_time_to_string() can use.
+ *
+ * @SOUP_DATE_HTTP and @SOUP_DATE_COOKIE always coerce the time to
+ * UTC.
+ *
+ * This enum may be extended with more values in future releases.
+ **/
+
+/* Do not internationalize */
+static const char *const months[] = {
+       "Jan", "Feb", "Mar", "Apr", "May", "Jun",
+       "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
+};
+
+/* Do not internationalize */
+static const char *const days[] = {
+       "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"
+};
+
+/**
+ * soup_date_time_to_string:
+ * @date: a #GDateTime
+ * @format: the format to generate the date in
+ *
+ * Converts @date to a string in the format described by @format.
+ *
+ * Return: (transfer full): @date as a string or %NULL
+ **/
+char *
+soup_date_time_to_string (GDateTime      *date,
+                          SoupDateFormat  format)
+{
+       g_return_val_if_fail (date != NULL, NULL);
+
+       if (format == SOUP_DATE_HTTP || format == SOUP_DATE_COOKIE) {
+               /* HTTP and COOKIE formats require UTC timestamp, so coerce
+                * @date if it's non-UTC.
+                */
+               GDateTime *utcdate = g_date_time_to_utc (date);
+                char *date_format;
+                char *formatted_date;
+
+                // We insert days/months ourselves to avoid locale specific formatting
+                if (format == SOUP_DATE_HTTP) {
+                       /* "Sun, 06 Nov 1994 08:49:37 GMT" */
+                        date_format = g_strdup_printf ("%s, %%d %s %%Y %%T GMT",
+                                                       days[g_date_time_get_day_of_week (utcdate) - 1],
+                                                       months[g_date_time_get_month (utcdate) - 1]);
+                } else {
+                       /* "Sun, 06-Nov-1994 08:49:37 GMT" */
+                        date_format = g_strdup_printf ("%s, %%d-%s-%%Y %%T GMT",
+                                                       days[g_date_time_get_day_of_week (utcdate) - 1],
+                                                       months[g_date_time_get_month (utcdate) - 1]);
+               }
+
+                formatted_date = g_date_time_format (utcdate, (const char*)date_format);
+                g_date_time_unref (utcdate);
+                g_free (date_format);
+                return formatted_date;
+       }
+
+        g_return_val_if_reached (NULL);
+}
+
+static inline gboolean
+parse_day (int *day, const char **date_string)
+{
+       char *end;
+
+       *day = strtoul (*date_string, &end, 10);
+       if (end == (char *)*date_string)
+               return FALSE;
+
+       while (*end == ' ' || *end == '-')
+               end++;
+       *date_string = end;
+       return TRUE;
+}
+
+static inline gboolean
+parse_month (int *month, const char **date_string)
+{
+       int i;
+
+       for (i = 0; i < G_N_ELEMENTS (months); i++) {
+               if (!g_ascii_strncasecmp (*date_string, months[i], 3)) {
+                       *month = i + 1;
+                       *date_string += 3;
+                       while (**date_string == ' ' || **date_string == '-')
+                               (*date_string)++;
+                       return TRUE;
+               }
+       }
+       return FALSE;
+}
+
+static inline gboolean
+parse_year (int *year, const char **date_string)
+{
+       char *end;
+
+       *year = strtoul (*date_string, &end, 10);
+       if (end == (char *)*date_string)
+               return FALSE;
+
+       if (end == (char *)*date_string + 2) {
+               if (*year < 70)
+                       *year += 2000;
+               else
+                       *year += 1900;
+       } else if (end == (char *)*date_string + 3)
+               *year += 1900;
+
+       while (*end == ' ' || *end == '-')
+               end++;
+       *date_string = end;
+       return TRUE;
+}
+
+static inline gboolean
+parse_time (int *hour, int *minute, int *second, const char **date_string)
+{
+       char *p, *end;
+
+       *hour = strtoul (*date_string, &end, 10);
+       if (end == (char *)*date_string || *end++ != ':')
+               return FALSE;
+       p = end;
+       *minute = strtoul (p, &end, 10);
+       if (end == p || *end++ != ':')
+               return FALSE;
+       p = end;
+       *second = strtoul (p, &end, 10);
+       if (end == p)
+               return FALSE;
+       p = end;
+
+       while (*p == ' ')
+               p++;
+       *date_string = p;
+       return TRUE;
+}
+
+static inline gboolean
+parse_timezone (GTimeZone **timezone, const char **date_string)
+{
+        gint32 offset_minutes;
+        gboolean utc;
+
+       if (!**date_string) {
+                utc = FALSE;
+               offset_minutes = 0;
+       } else if (**date_string == '+' || **date_string == '-') {
+               gulong val;
+               int sign = (**date_string == '+') ? 1 : -1;
+               val = strtoul (*date_string + 1, (char **)date_string, 10);
+               if (**date_string == ':')
+                       val = 60 * val + strtoul (*date_string + 1, (char **)date_string, 10);
+               else
+                       val =  60 * (val / 100) + (val % 100);
+               offset_minutes = sign * val;
+                utc = (sign == -1) && !val;
+       } else if (**date_string == 'Z') {
+               offset_minutes = 0;
+                utc = TRUE;
+               (*date_string)++;
+       } else if (!strcmp (*date_string, "GMT") ||
+                  !strcmp (*date_string, "UTC")) {
+               offset_minutes = 0;
+                utc = TRUE;
+               (*date_string) += 3;
+       } else if (strchr ("ECMP", **date_string) &&
+                  ((*date_string)[1] == 'D' || (*date_string)[1] == 'S') &&
+                  (*date_string)[2] == 'T') {
+               offset_minutes = -60 * (5 * strcspn ("ECMP", *date_string));
+               if ((*date_string)[1] == 'D')
+                       offset_minutes += 60;
+                utc = FALSE;
+       } else
+               return FALSE;
+
+        if (utc)
+                *timezone = g_time_zone_new_utc ();
+        else
+                *timezone = g_time_zone_new_offset (offset_minutes * 60);
+       return TRUE;
+}
+
+static GDateTime *
+parse_textual_date (const char *date_string)
+{
+        int month, day, year, hour, minute, second;
+        GTimeZone *tz = NULL;
+        GDateTime *date;
+
+       /* If it starts with a word, it must be a weekday, which we skip */
+       if (g_ascii_isalpha (*date_string)) {
+               while (g_ascii_isalpha (*date_string))
+                       date_string++;
+               if (*date_string == ',')
+                       date_string++;
+               while (g_ascii_isspace (*date_string))
+                       date_string++;
+       }
+
+       /* If there's now another word, this must be an asctime-date */
+       if (g_ascii_isalpha (*date_string)) {
+               /* (Sun) Nov  6 08:49:37 1994 */
+               if (!parse_month (&month, &date_string) ||
+                   !parse_day (&day, &date_string) ||
+                   !parse_time (&hour, &minute, &second, &date_string) ||
+                   !parse_year (&year, &date_string))
+                       return FALSE;
+
+               /* There shouldn't be a timezone, but check anyway */
+               parse_timezone (&tz, &date_string);
+       } else {
+               /* Non-asctime date, so some variation of
+                * (Sun,) 06 Nov 1994 08:49:37 GMT
+                */
+               if (!parse_day (&day, &date_string) ||
+                   !parse_month (&month, &date_string) ||
+                   !parse_year (&year, &date_string) ||
+                   !parse_time (&hour, &minute, &second, &date_string))
+                       return FALSE;
+
+               /* This time there *should* be a timezone, but we
+                * survive if there isn't.
+                */
+               parse_timezone (&tz, &date_string);
+       }
+
+        if (!tz)
+                tz = g_time_zone_new_utc ();
+
+        date = g_date_time_new (tz, year, month, day, hour, minute, second);
+        g_time_zone_unref (tz);
+
+        return date;
+}
+
+/**
+ * soup_date_time_new_from_http_string:
+ * @date_string: The date as a string
+ *
+ * Parses @date_string and tries to extract a date from it. This
+ * recognizes all of the "HTTP-date" formats from RFC 2616, RFC 2822
+ * dates, and reasonable approximations thereof. (Eg, it is lenient about
+ * whitespace, leading "0"s, etc.)
+ *
+ * Return value: (nullable): a new #GDateTime, or %NULL if @date_string
+ * could not be parsed.
+ **/
+GDateTime *
+soup_date_time_new_from_http_string (const char *date_string)
+{
+        g_return_val_if_fail (date_string != NULL, NULL);
+
+       while (g_ascii_isspace (*date_string))
+               date_string++;
+
+       /* Previous versions of this library supported parsing iso8601 strings
+           however g_date_time_new_from_iso8601() should be used now. Just
+           catch those in case for testing.
+         */
+       if (G_UNLIKELY (g_ascii_isdigit (*date_string) && !strpbrk (date_string, "JFMASOND")))
+                g_return_val_if_reached (NULL);
+
+       return parse_textual_date (date_string);
+}
diff --git a/libsoup/soup-date-utils.h b/libsoup/soup-date-utils.h
new file mode 100644
index 00000000..dbd4581c
--- /dev/null
+++ b/libsoup/soup-date-utils.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2020 Igalia, S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#pragma once
+
+#include "soup-types.h"
+
+G_BEGIN_DECLS
+
+typedef enum {
+       SOUP_DATE_HTTP = 1,
+       SOUP_DATE_COOKIE,
+} SoupDateFormat;
+
+SOUP_AVAILABLE_IN_2_70
+char           *soup_date_time_to_string            (GDateTime      *date,
+                                                     SoupDateFormat  format);
+
+SOUP_AVAILABLE_IN_2_70
+GDateTime      *soup_date_time_new_from_http_string (const char     *date_string);
+
+G_END_DECLS
diff --git a/libsoup/soup-server.c b/libsoup/soup-server.c
index 5e44b6ea..ae2301d4 100644
--- a/libsoup/soup-server.c
+++ b/libsoup/soup-server.c
@@ -971,7 +971,7 @@ got_headers (SoupMessage *msg, SoupClientContext *client)
        SoupServerPrivate *priv = soup_server_get_instance_private (server);
        SoupServerHandler *handler;
        SoupURI *uri;
-       SoupDate *date;
+       GDateTime *date;
        char *date_string;
        SoupAuthDomain *domain;
        GSList *iter;
@@ -979,12 +979,12 @@ got_headers (SoupMessage *msg, SoupClientContext *client)
        char *auth_user;
 
        /* Add required response headers */
-       date = soup_date_new_from_now (0);
-       date_string = soup_date_to_string (date, SOUP_DATE_HTTP);
+       date = g_date_time_new_now_utc ();
+       date_string = soup_date_time_to_string (date, SOUP_DATE_HTTP);
        soup_message_headers_replace (msg->response_headers, "Date",
                                      date_string);
        g_free (date_string);
-       soup_date_free (date);
+       g_date_time_unref (date);
 
        if (msg->status_code != 0)
                return;
diff --git a/libsoup/soup-types.h b/libsoup/soup-types.h
index b489cb5c..209e020a 100644
--- a/libsoup/soup-types.h
+++ b/libsoup/soup-types.h
@@ -20,7 +20,6 @@ typedef struct _SoupAuth                SoupAuth;
 typedef struct _SoupAuthDomain          SoupAuthDomain;
 typedef struct _SoupCookie              SoupCookie;
 typedef struct _SoupCookieJar           SoupCookieJar;
-typedef struct _SoupDate                SoupDate;
 typedef struct _SoupHSTSEnforcer        SoupHSTSEnforcer;
 typedef struct _SoupHSTSPolicy          SoupHSTSPolicy;
 typedef struct _SoupMessage             SoupMessage;
diff --git a/libsoup/soup.h b/libsoup/soup.h
index f0511b93..4e4d4a62 100644
--- a/libsoup/soup.h
+++ b/libsoup/soup.h
@@ -28,7 +28,7 @@ extern "C" {
 #include "cookies/soup-cookie-jar.h"
 #include "cookies/soup-cookie-jar-db.h"
 #include "cookies/soup-cookie-jar-text.h"
-#include "soup-date.h"
+#include "soup-date-utils.h"
 #include "soup-enum-types.h"
 #include "soup-form.h"
 #include "soup-headers.h"
diff --git a/tests/cache-test.c b/tests/cache-test.c
index 29b409ff..34e26be8 100644
--- a/tests/cache-test.c
+++ b/tests/cache-test.c
@@ -55,19 +55,16 @@ server_callback (SoupServer *server, SoupMessage *msg,
        header = soup_message_headers_get_one (msg->request_headers,
                                               "If-Modified-Since");
        if (header && last_modified) {
-               SoupDate *date;
-               time_t lastmod, check;
+               GDateTime *modified_date, *header_date;
 
-               date = soup_date_new_from_string (last_modified);
-               lastmod = soup_date_to_time_t (date);
-               soup_date_free (date);
+               modified_date = soup_date_time_new_from_http_string (last_modified);
+               header_date = soup_date_time_new_from_http_string (header);
 
-               date = soup_date_new_from_string (header);
-               check = soup_date_to_time_t (date);
-               soup_date_free (date);
-
-               if (lastmod <= check)
+               if (g_date_time_compare (modified_date, header_date) <= 0)
                        status = SOUP_STATUS_NOT_MODIFIED;
+
+                g_date_time_unref (modified_date);
+                g_date_time_unref (header_date);
        }
 
        header = soup_message_headers_get_one (msg->request_headers,
diff --git a/tests/date-test.c b/tests/date-test.c
index 97ae221f..27cf6805 100644
--- a/tests/date-test.c
+++ b/tests/date-test.c
@@ -7,27 +7,27 @@
 
 static void check_ok (gconstpointer data);
 
-static SoupDate *
+static GDateTime *
 make_date (const char *strdate)
 {
        char *dup;
-       SoupDate *date;
+       GDateTime *date;
 
-       /* We do it this way so that if soup_date_new_from_string()
+       /* We do it this way so that if soup_date_time_new_from_http_string()
         * reads off the end of the string, it will trigger an error
         * when valgrinding, rather than just reading the start of the
         * next const string.
         */
        dup = g_strdup (strdate);
-       date = soup_date_new_from_string (dup);
+       date = soup_date_time_new_from_http_string (dup);
        g_free (dup);
        return date;
 }
 
-static SoupDate *
+static GDateTime *
 check_correct_date (const char *strdate)
 {
-       SoupDate *date;
+       GDateTime *date;
 
        date = make_date (strdate);
        if (!date) {
@@ -35,12 +35,12 @@ check_correct_date (const char *strdate)
                return NULL;
        }
 
-       g_assert_cmpint (date->year,   ==, 2004);
-       g_assert_cmpint (date->month,  ==, 11);
-       g_assert_cmpint (date->day,    ==, 6);
-       g_assert_cmpint (date->hour,   ==, 8);
-       g_assert_cmpint (date->minute, ==, 9);
-       g_assert_cmpint (date->second, ==, 7);
+       g_assert_cmpint (g_date_time_get_year (date),   ==, 2004);
+       g_assert_cmpint (g_date_time_get_month (date),  ==, 11);
+       g_assert_cmpint (g_date_time_get_day_of_month (date), ==, 6);
+       g_assert_cmpint (g_date_time_get_hour (date),   ==, 8);
+       g_assert_cmpint (g_date_time_get_minute (date), ==, 9);
+       g_assert_cmpint (g_date_time_get_second (date), ==, 7);
 
        return date;
 }
@@ -54,17 +54,13 @@ typedef struct {
 static const GoodDate good_dates[] = {
        { SOUP_DATE_HTTP,            "Sat, 06 Nov 2004 08:09:07 GMT", NULL },
        { SOUP_DATE_COOKIE,          "Sat, 06-Nov-2004 08:09:07 GMT", NULL },
-       { SOUP_DATE_RFC2822,         "Sat, 6 Nov 2004 08:09:07 -0430", "579055" },
-       { SOUP_DATE_ISO8601_COMPACT, "20041106T080907", NULL },
-       { SOUP_DATE_ISO8601_FULL,    "2004-11-06T08:09:07", NULL },
-       { SOUP_DATE_ISO8601_XMLRPC,  "20041106T08:09:07", NULL }
 };
 
 static void
 check_good (gconstpointer data)
 {
        GoodDate *good = (GoodDate *)data;
-       SoupDate *date;
+       GDateTime *date;
        char *strdate2;
 
        if (good->bugref)
@@ -74,8 +70,8 @@ check_good (gconstpointer data)
        if (!date)
                return;
 
-       strdate2 = soup_date_to_string (date, good->format);
-       soup_date_free (date);
+       strdate2 = soup_date_time_to_string (date, good->format);
+       g_date_time_unref (date);
 
        soup_test_assert (strcmp (good->date, strdate2) == 0,
                          "restringification failed: '%s' -> '%s'\n",
@@ -114,12 +110,6 @@ static const OkDate ok_dates[] = {
        { "Sat Nov 6 08:09:07 2004", NULL },
        { "Sat Nov  6 08:09:07 2004 GMT", NULL },
 
-       /* ISO 8601 */
-       { "2004-11-06T08:09:07Z", NULL },
-       { "20041106T08:09:07Z", NULL },
-       { "20041106T08:09:07+00:00", NULL },
-       { "20041106T080907+00:00", NULL },
-
        /* Netscape cookie spec date, and broken variants */
        { "Sat, 06-Nov-2004 08:09:07 GMT", NULL },
        { "Sat, 6-Nov-2004 08:09:07 GMT", NULL },
@@ -143,7 +133,7 @@ static void
 check_ok (gconstpointer data)
 {
        OkDate *ok = (OkDate *)data;
-       SoupDate *date;
+       GDateTime *date;
 
        if (ok->bugref)
                g_test_bug (ok->bugref);
@@ -151,29 +141,7 @@ check_ok (gconstpointer data)
        date = check_correct_date (ok->date);
        if (!date)
                return;
-       soup_date_free (date);
-}
-
-#define TIME_T 1099728547L
-#define TIME_T_STRING "1099728547"
-
-static void
-check_ok_time_t (void)
-{
-       SoupDate *date;
-
-       date = soup_date_new_from_time_t (TIME_T);
-
-       g_assert_cmpint (date->year,   ==, 2004);
-       g_assert_cmpint (date->month,  ==, 11);
-       g_assert_cmpint (date->day,    ==, 6);
-       g_assert_cmpint (date->hour,   ==, 8);
-       g_assert_cmpint (date->minute, ==, 9);
-       g_assert_cmpint (date->second, ==, 7);
-
-       g_assert_cmpuint (TIME_T, ==, soup_date_to_time_t (date));
-
-       soup_date_free (date);
+       g_date_time_unref (date);
 }
 
 typedef struct {
@@ -221,7 +189,7 @@ static void
 check_bad (gconstpointer data)
 {
        BadDate *bad = (BadDate *)data;
-       SoupDate *date;
+       GDateTime *date;
 
        if (bad->bugref)
                g_test_bug (bad->bugref);
@@ -230,14 +198,18 @@ check_bad (gconstpointer data)
        soup_test_assert (date == NULL,
                          "date parsing succeeded for '%s': %d %d %d - %d %d %d",
                          bad->date,
-                         date->year, date->month, date->day,
-                         date->hour, date->minute, date->second);
-       g_clear_pointer (&date, soup_date_free);
+                          g_date_time_get_year (date),
+                          g_date_time_get_month (date),
+                          g_date_time_get_day_of_month (date),
+                          g_date_time_get_hour (date),
+                          g_date_time_get_minute (date),
+                          g_date_time_get_second (date));
+       g_clear_pointer (&date, g_date_time_unref);
 }
 
 typedef struct {
        const char *source;
-       const char *http, *cookie, *rfc2822, *compact, *full, *xmlrpc;
+       const char *http, *cookie;
 } DateConversion;
 
 static const DateConversion conversions[] = {
@@ -245,98 +217,38 @@ static const DateConversion conversions[] = {
        { "Sat, 06 Nov 2004 08:09:07 GMT",
 
          "Sat, 06 Nov 2004 08:09:07 GMT",
-         "Sat, 06-Nov-2004 08:09:07 GMT",
-         "Sat, 6 Nov 2004 08:09:07 +0000",
-         "20041106T080907Z",
-         "2004-11-06T08:09:07Z",
-         "20041106T08:09:07" },
+         "Sat, 06-Nov-2004 08:09:07 GMT" },
 
        /* RFC2822 GMT */
        { "Sat, 6 Nov 2004 08:09:07 +0000",
 
          "Sat, 06 Nov 2004 08:09:07 GMT",
-         "Sat, 06-Nov-2004 08:09:07 GMT",
-         "Sat, 6 Nov 2004 08:09:07 +0000",
-         "20041106T080907Z",
-         "2004-11-06T08:09:07Z",
-         "20041106T08:09:07" },
+         "Sat, 06-Nov-2004 08:09:07 GMT" },
 
        /* RFC2822 with positive offset */
        { "Sat, 6 Nov 2004 08:09:07 +0430",
 
-         "Sat, 06 Nov 2004 04:39:07 GMT",
-         "Sat, 06-Nov-2004 04:39:07 GMT",
-         "Sat, 6 Nov 2004 08:09:07 +0430",
-         "20041106T080907+0430",
-         "2004-11-06T08:09:07+04:30",
-         "20041106T08:09:07" },
+         "Sat, 06 Nov 2004 03:39:07 GMT",
+         "Sat, 06-Nov-2004 03:39:07 GMT" },
 
        /* RFC2822 with negative offset */
        { "Sat, 6 Nov 2004 08:09:07 -0430",
 
          "Sat, 06 Nov 2004 12:39:07 GMT",
-         "Sat, 06-Nov-2004 12:39:07 GMT",
-         "Sat, 6 Nov 2004 08:09:07 -0430",
-         "20041106T080907-0430",
-         "2004-11-06T08:09:07-04:30",
-         "20041106T08:09:07" },
+         "Sat, 06-Nov-2004 12:39:07 GMT" },
 
        /* RFC2822 floating */
        { "Sat, 6 Nov 2004 08:09:07 -0000",
 
          "Sat, 06 Nov 2004 08:09:07 GMT",
-         "Sat, 06-Nov-2004 08:09:07 GMT",
-         "Sat, 6 Nov 2004 08:09:07 -0000",
-         "20041106T080907",
-         "2004-11-06T08:09:07",
-         "20041106T08:09:07" },
-
-       /* ISO GMT */
-       { "2004-11-06T08:09:07Z",
-
-         "Sat, 06 Nov 2004 08:09:07 GMT",
-         "Sat, 06-Nov-2004 08:09:07 GMT",
-         "Sat, 6 Nov 2004 08:09:07 +0000",
-         "20041106T080907Z",
-         "2004-11-06T08:09:07Z",
-         "20041106T08:09:07" },
-
-       /* ISO with positive offset */
-       { "2004-11-06T08:09:07+04:30",
-
-         "Sat, 06 Nov 2004 04:39:07 GMT",
-         "Sat, 06-Nov-2004 04:39:07 GMT",
-         "Sat, 6 Nov 2004 08:09:07 +0430",
-         "20041106T080907+0430",
-         "2004-11-06T08:09:07+04:30",
-         "20041106T08:09:07" },
-
-       /* ISO with negative offset */
-       { "2004-11-06T08:09:07-04:30",
-
-         "Sat, 06 Nov 2004 12:39:07 GMT",
-         "Sat, 06-Nov-2004 12:39:07 GMT",
-         "Sat, 6 Nov 2004 08:09:07 -0430",
-         "20041106T080907-0430",
-         "2004-11-06T08:09:07-04:30",
-         "20041106T08:09:07" },
-
-       /* ISO floating */
-       { "2004-11-06T08:09:07",
-
-         "Sat, 06 Nov 2004 08:09:07 GMT",
-         "Sat, 06-Nov-2004 08:09:07 GMT",
-         "Sat, 6 Nov 2004 08:09:07 -0000",
-         "20041106T080907",
-         "2004-11-06T08:09:07",
-         "20041106T08:09:07" }
+         "Sat, 06-Nov-2004 08:09:07 GMT" }
 };
 
 static void
 check_conversion (gconstpointer data)
 {
        const DateConversion *conv = data;
-       SoupDate *date;
+       GDateTime *date;
        char *str;
 
        date = make_date (conv->source);
@@ -345,31 +257,15 @@ check_conversion (gconstpointer data)
                return;
        }
 
-       str = soup_date_to_string (date, SOUP_DATE_HTTP);
+       str = soup_date_time_to_string (date, SOUP_DATE_HTTP);
        g_assert_cmpstr (str, ==, conv->http);
        g_free (str);
 
-       str = soup_date_to_string (date, SOUP_DATE_COOKIE);
+       str = soup_date_time_to_string (date, SOUP_DATE_COOKIE);
        g_assert_cmpstr (str, ==, conv->cookie);
        g_free (str);
 
-       str = soup_date_to_string (date, SOUP_DATE_RFC2822);
-       g_assert_cmpstr (str, ==, conv->rfc2822);
-       g_free (str);
-
-       str = soup_date_to_string (date, SOUP_DATE_ISO8601_COMPACT);
-       g_assert_cmpstr (str, ==, conv->compact);
-       g_free (str);
-
-       str = soup_date_to_string (date, SOUP_DATE_ISO8601_FULL);
-       g_assert_cmpstr (str, ==, conv->full);
-       g_free (str);
-
-       str = soup_date_to_string (date, SOUP_DATE_ISO8601_XMLRPC);
-       g_assert_cmpstr (str, ==, conv->xmlrpc);
-       g_free (str);
-
-       soup_date_free (date);
+       g_date_time_unref (date);
 }
 
 int
@@ -391,7 +287,6 @@ main (int argc, char **argv)
                g_test_add_data_func (path, &ok_dates[i], check_ok);
                g_free (path);
        }
-       g_test_add_func ("/date/ok/" TIME_T_STRING, check_ok_time_t);
 
        for (i = 0; i < G_N_ELEMENTS (bad_dates); i++) {
                path = g_strdup_printf ("/date/bad/%s", bad_dates[i].date);



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