libpurple/util.c

changeset 34243
5019efec9d8f
parent 34218
de45cb0670a5
parent 34229
6a1aea2866aa
child 34297
0f1f0b8c84f8
child 34754
3f68e191c0a0
equal deleted inserted replaced
34241:8b905ef8081d 34243:5019efec9d8f
738 struct tm t; 738 struct tm t;
739 const gchar *str; 739 const gchar *str;
740 gint year = 0; 740 gint year = 0;
741 long tzoff = PURPLE_NO_TZ_OFF; 741 long tzoff = PURPLE_NO_TZ_OFF;
742 time_t retval; 742 time_t retval;
743 gboolean mktime_with_utc = TRUE; 743 gboolean mktime_with_utc = FALSE;
744 744
745 if (rest != NULL) 745 if (rest != NULL)
746 *rest = NULL; 746 *rest = NULL;
747 747
748 g_return_val_if_fail(timestamp != NULL, 0); 748 g_return_val_if_fail(timestamp != NULL, 0);
839 do { 839 do {
840 str++; 840 str++;
841 } while (*str >= '0' && *str <= '9'); 841 } while (*str >= '0' && *str <= '9');
842 } 842 }
843 843
844 sign = (*str == '+') ? -1 : 1; 844 sign = (*str == '+') ? 1 : -1;
845 845
846 /* Process the timezone */ 846 /* Process the timezone */
847 if (*str == '+' || *str == '-') { 847 if (*str == '+' || *str == '-') {
848 str++; 848 str++;
849 849
850 if (((sscanf(str, "%02d:%02d", &tzhrs, &tzmins) == 2 && (str += 5)) || 850 if (((sscanf(str, "%02d:%02d", &tzhrs, &tzmins) == 2 && (str += 5)) ||
851 (sscanf(str, "%02d%02d", &tzhrs, &tzmins) == 2 && (str += 4)))) 851 (sscanf(str, "%02d%02d", &tzhrs, &tzmins) == 2 && (str += 4))))
852 { 852 {
853 mktime_with_utc = TRUE;
853 tzoff = tzhrs * 60 * 60 + tzmins * 60; 854 tzoff = tzhrs * 60 * 60 + tzmins * 60;
854 tzoff *= sign; 855 tzoff *= sign;
855 } else {
856 if (rest != NULL && *str != '\0')
857 *rest = str;
858
859 return 0;
860 } 856 }
861 } else if (*str == 'Z') { 857 } else if (*str == 'Z') {
862 /* 'Z' = Zulu = UTC */ 858 /* 'Z' = Zulu = UTC */
863 str++; 859 str++;
864 utc = TRUE; 860 mktime_with_utc = TRUE;
865 } else if (!utc) { 861 tzoff = 0;
866 /* Local Time */
867 t.tm_isdst = -1;
868 mktime_with_utc = FALSE;
869 } 862 }
870 863
871 if (utc) 864 if (!mktime_with_utc)
872 tzoff = 0; 865 {
866 /* No timezone specified. */
867
868 if (utc) {
869 mktime_with_utc = TRUE;
870 tzoff = 0;
871 } else {
872 /* Local Time */
873 t.tm_isdst = -1;
874 }
875 }
873 } 876 }
874 } 877 }
875 878
876 if (rest != NULL && *str != '\0') { 879 if (rest != NULL && *str != '\0') {
877 /* Strip trailing whitespace */ 880 /* Strip trailing whitespace */

mercurial