35 lines
		
	
	
		
			799 B
		
	
	
	
		
			Dart
		
	
	
	
	
	
			
		
		
	
	
			35 lines
		
	
	
		
			799 B
		
	
	
	
		
			Dart
		
	
	
	
	
	
| DateTime parseRfc822Date(String date) {
 | |
|   // Split the date string into components
 | |
|   final parts = date.split(' ');
 | |
| 
 | |
|   // Map the month names to their corresponding numbers
 | |
|   const monthMap = {
 | |
|     'Jan': 1,
 | |
|     'Feb': 2,
 | |
|     'Mar': 3,
 | |
|     'Apr': 4,
 | |
|     'May': 5,
 | |
|     'Jun': 6,
 | |
|     'Jul': 7,
 | |
|     'Aug': 8,
 | |
|     'Sep': 9,
 | |
|     'Oct': 10,
 | |
|     'Nov': 11,
 | |
|     'Dec': 12,
 | |
|   };
 | |
| 
 | |
|   // Extract the components
 | |
|   final day = int.parse(parts[1]);
 | |
|   final month = monthMap[parts[2]]!;
 | |
|   final year = int.parse(parts[3]);
 | |
|   final timeParts = parts[4].split(':');
 | |
|   final hour = int.parse(timeParts[0]);
 | |
|   final minute = int.parse(timeParts[1]);
 | |
|   final second = int.parse(timeParts[2]);
 | |
| 
 | |
|   // Create the DateTime object
 | |
|   DateTime dateTime = DateTime(year, month, day, hour, minute, second);
 | |
| 
 | |
|   return dateTime;
 | |
| }
 |