mirror of
				https://gitlab.gnome.org/GNOME/glib.git
				synced 2025-11-04 01:58:54 +01:00 
			
		
		
		
	Merged from trunk:
2007-12-19 Emmanuele Bassi <ebassi@gnome.org> Merged from trunk: * glib/gtimer.c (g_time_val_from_iso8601): Fix the date validation check. (#503029) * tests/testglib.c (various_string_tests): Add an invalid date for testing the above fix. svn path=/branches/glib-2-14/; revision=6161
This commit is contained in:
		
				
					committed by
					
						
						Emmanuele Bassi
					
				
			
			
				
	
			
			
			
						parent
						
							8b57c219d0
						
					
				
				
					commit
					e3e92b4d3f
				
			
							
								
								
									
										10
									
								
								ChangeLog
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								ChangeLog
									
									
									
									
									
								
							@@ -1,3 +1,13 @@
 | 
			
		||||
2007-12-19  Emmanuele Bassi  <ebassi@gnome.org>
 | 
			
		||||
 | 
			
		||||
	Merged from trunk:
 | 
			
		||||
 | 
			
		||||
	* glib/gtimer.c (g_time_val_from_iso8601): Fix the date validation
 | 
			
		||||
	check. (#503029)
 | 
			
		||||
 | 
			
		||||
	* tests/testglib.c (various_string_tests): Add an invalid date
 | 
			
		||||
	for testing the above fix.
 | 
			
		||||
 | 
			
		||||
2007-12-13  Bastien Nocera  <hadess@hadess.net>
 | 
			
		||||
 | 
			
		||||
	* glib/gtimer.c: (g_time_val_from_iso8601):
 | 
			
		||||
 
 | 
			
		||||
@@ -312,9 +312,11 @@ g_time_val_from_iso8601 (const gchar *iso_date,
 | 
			
		||||
   * have an ISO 8601 date */
 | 
			
		||||
  while (g_ascii_isspace (*iso_date))
 | 
			
		||||
    iso_date++;
 | 
			
		||||
 | 
			
		||||
  if (*iso_date == '\0')
 | 
			
		||||
    return FALSE;
 | 
			
		||||
  if (!g_ascii_isdigit (*iso_date) || iso_date != '-' || *iso_date != '+')
 | 
			
		||||
 | 
			
		||||
  if (!g_ascii_isdigit (*iso_date) && *iso_date != '-' && *iso_date != '+')
 | 
			
		||||
    return FALSE;
 | 
			
		||||
 | 
			
		||||
  val = strtoul (iso_date, (char **)&iso_date, 10);
 | 
			
		||||
 
 | 
			
		||||
@@ -1186,6 +1186,7 @@ main (int   argc,
 | 
			
		||||
  g_timer_destroy(timer);
 | 
			
		||||
  g_timer_destroy(timer2);
 | 
			
		||||
 | 
			
		||||
#define REF_INVALID  "Wed Dec 19 17:20:20 GMT 2007"
 | 
			
		||||
#define REF_SEC_UTC  320063760
 | 
			
		||||
#define REF_STR_UTC  "1980-02-22T10:36:00Z"
 | 
			
		||||
#define REF_STR_CEST "1980-02-22T12:36:00+02:00"
 | 
			
		||||
@@ -1194,6 +1195,7 @@ main (int   argc,
 | 
			
		||||
  g_print ("checking g_time_val_from_iso8601...\n");
 | 
			
		||||
  ref_date.tv_sec = REF_SEC_UTC;
 | 
			
		||||
  ref_date.tv_usec = 0;
 | 
			
		||||
  g_assert (g_time_val_from_iso8601 (REF_INVALID, &date) == FALSE);
 | 
			
		||||
  g_assert (g_time_val_from_iso8601 (REF_STR_UTC, &date) != FALSE);
 | 
			
		||||
  g_print ("\t=> UTC stamp = %ld (should be: %ld) (%ld off)\n", date.tv_sec, ref_date.tv_sec, date.tv_sec - ref_date.tv_sec);
 | 
			
		||||
  g_assert (date.tv_sec == ref_date.tv_sec);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user