~ubuntu-branches/ubuntu/saucy/evolution-data-server/saucy

« back to all changes in this revision

Viewing changes to libedataserver/e-time-utils.c

  • Committer: Package Import Robot
  • Author(s): Chris Coulson
  • Date: 2012-10-08 12:58:16 UTC
  • mfrom: (181.1.7 quantal)
  • Revision ID: package-import@ubuntu.com-20121008125816-i3n76e8c0m64e7xp
Tags: 3.6.0-0ubuntu2
* Fix LP: #1038047 part 1 - Don't abort in e_source_registry_new* when a
  problem occurs connecting to the Dbus service
  - add debian/patches/dont-abort-in-e_source_registry_new.patch
  - update debian/patches/series
* Fix LP: #1038047 part 2 - libedataserver depends on
  evolution-data-server-common to ensure that the GSettings schemas are
  present
  - update debian/control

Show diffs side-by-side

added added

removed removed

Lines of Context:
1573
1573
static gboolean
1574
1574
has_correct_date (const struct tm *value)
1575
1575
{
1576
 
        const gint days_in_month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
 
1576
        const gint days_in_month[12] = {
 
1577
                31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
1577
1578
        gint days, year;
1578
1579
 
1579
1580
        g_return_val_if_fail (value != NULL, FALSE);
1581
1582
 
1582
1583
        year = value->tm_year  + 1900;
1583
1584
        days = days_in_month[value->tm_mon];
1584
 
        if (value->tm_mon == 1 && ((year <= 1752) ? (!(year % 4)) : ((!(year % 4) && (year % 100)) || !(year % 400))))
 
1585
        if (value->tm_mon == 1 &&
 
1586
                ((year <= 1752) ? (!(year % 4)) :
 
1587
                ((!(year % 4) && (year % 100)) || !(year % 400))))
1585
1588
                days++;
1586
1589
 
1587
1590
        return value->tm_mday >= 1 && value->tm_mday <= days;
1786
1789
        g_return_val_if_fail (result != NULL, E_TIME_PARSE_INVALID);
1787
1790
 
1788
1791
        /* according to the current locale */
1789
 
        format [0] = ("%x");
 
1792
        format[0] = ("%x");
1790
1793
 
1791
1794
        /* according to the current locale with forced 4-digit year*/
1792
1795
        format[1] = e_time_get_d_fmt_with_4digit_year ();
1793
1796
 
1794
1797
        /* strptime format of a weekday and a date. */
1795
 
        format [2] = _("%a %m/%d/%Y");
 
1798
        format[2] = _("%a %m/%d/%Y");
1796
1799
 
1797
1800
        /* This is the preferred date format for the locale. */
1798
 
        format [3] = _("%m/%d/%Y");
 
1801
        format[3] = _("%m/%d/%Y");
1799
1802
 
1800
1803
        if (two_digit_year) {
1801
1804
                /* when we need to know about two digit year, then always first try
1881
1884
        /* strptime format for time of day, without seconds 24-hour format. */
1882
1885
        format[num_formats++] = _("%H:%M");
1883
1886
 
1884
 
        /* strptime format for time of day, without seconds 24-hour format, and no colon. */
 
1887
        /* strptime format for time of day, without seconds 24-hour format,
 
1888
         * and no colon. */
1885
1889
        format[num_formats++] = _("%H%M");
1886
1890
 
1887
1891
        if (use_12_hour_formats) {
2088
2092
#if defined(HAVE_NL_LANGINFO)
2089
2093
        res = g_strdup (nl_langinfo (D_FMT) );
2090
2094
#elif defined(G_OS_WIN32)
2091
 
  #define GET_LOCALE_INFO(str, len) GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SLONGDATE, str, len)
 
2095
#define GET_LOCALE_INFO(str, len) \
 
2096
        GetLocaleInfoA (LOCALE_USER_DEFAULT, LOCALE_SLONGDATE, str, len)
2092
2097
        gint format_string_length = GET_LOCALE_INFO (NULL, 0);
2093
 
        if (format_string_length > 0)
2094
 
        {
2095
 
                gsize format_bytes_read, format_bytes_written;
2096
 
                gchar *format_string = g_strnfill (format_string_length + 1, '\0');
 
2098
        if (format_string_length > 0) {
 
2099
                gsize format_bytes_read;
 
2100
                gsize format_bytes_written;
 
2101
                gchar *format_string;
 
2102
 
 
2103
                format_string = g_strnfill (format_string_length + 1, '\0');
2097
2104
                GET_LOCALE_INFO (format_string, format_string_length);
2098
 
                res = g_locale_to_utf8 (format_string, format_string_length, &format_bytes_read, &format_bytes_written, NULL);
 
2105
                res = g_locale_to_utf8 (
 
2106
                        format_string,
 
2107
                        format_string_length,
 
2108
                        &format_bytes_read,
 
2109
                        &format_bytes_written,
 
2110
                        NULL);
2099
2111
                g_free (format_string);
 
2112
 
2100
2113
                /* now, convert the res to format of nl_langinfo */
2101
 
                _e_string_replace(&res, "\\bd\\b", "%#d");      /* d -> %#d */
2102
 
                _e_string_replace(&res, "\\bdd\\b", "%d");      /* dd -> %d */
2103
 
                _e_string_replace(&res, "\\bddd\\b", "%a");     /* ddd -> %a */
2104
 
                _e_string_replace(&res, "\\bdddd\\b", "%A");    /* dddd -> %A */
2105
 
                _e_string_replace(&res, "\\bM\\b", "%#m");      /* M -> %#m */
2106
 
                _e_string_replace(&res, "\\bMM\\b", "%m");      /* MM -> %m */
2107
 
                _e_string_replace(&res, "\\bMMM\\b", "%b");     /* MMM -> %b */
2108
 
                _e_string_replace(&res, "\\bMMMM\\b", "%B");    /* MMMM -> %B */
2109
 
                _e_string_replace(&res, "\\by\\b", "%#y");      /* y -> %y */
2110
 
                _e_string_replace(&res, "\\byy\\b", "%y");      /* yy -> %y*/
2111
 
                _e_string_replace(&res, "\\byyyy\\b", "%Y");    /* yyyy -> %Y */
2112
 
                _e_string_replace(&res, "\\byyyyy\\b", "%Y");   /* yyyyy -> %Y */
 
2114
                _e_string_replace (&res, "\\bd\\b", "%#d");     /* d -> %#d */
 
2115
                _e_string_replace (&res, "\\bdd\\b", "%d");     /* dd -> %d */
 
2116
                _e_string_replace (&res, "\\bddd\\b", "%a");    /* ddd -> %a */
 
2117
                _e_string_replace (&res, "\\bdddd\\b", "%A");   /* dddd -> %A */
 
2118
                _e_string_replace (&res, "\\bM\\b", "%#m");     /* M -> %#m */
 
2119
                _e_string_replace (&res, "\\bMM\\b", "%m");     /* MM -> %m */
 
2120
                _e_string_replace (&res, "\\bMMM\\b", "%b");    /* MMM -> %b */
 
2121
                _e_string_replace (&res, "\\bMMMM\\b", "%B");   /* MMMM -> %B */
 
2122
                _e_string_replace (&res, "\\by\\b", "%#y");     /* y -> %y */
 
2123
                _e_string_replace (&res, "\\byy\\b", "%y");     /* yy -> %y */
 
2124
                _e_string_replace (&res, "\\byyyy\\b", "%Y");   /* yyyy -> %Y */
 
2125
                _e_string_replace (&res, "\\byyyyy\\b", "%Y");  /* yyyyy -> %Y */
2113
2126
        }
2114
 
  #undef GET_LOCALE_INFO
2115
 
        /**TODO** implement this for other systems
2116
 
        */
 
2127
#undef GET_LOCALE_INFO
 
2128
        /* TODO Implement this for other systems. */
2117
2129
#else
2118
 
                /* this will not work for other systems */
 
2130
        /* This will not work for other systems. */
2119
2131
        res = g_strdup ("%x");
2120
2132
#endif
2121
2133