Index: entriescache
===================================================================
RCS file: /home/iwai/cvsroot/www/tips/plugin/entriescache,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- entriescache	19 Jun 2005 17:35:17 -0000	1.1
+++ entriescache	21 Jun 2005 18:10:52 -0000	1.2
@@ -23,8 +23,9 @@
 $use_date_tags = 1;			# Set to 1 to enable parsing meta- keywords
 							# for date tags
 
-$use_UK_dates = 0;			# Default is mm/dd/yy (US)
-							# Set to 1 to use dd/mm/yy (UK)
+$time_format = 'W3CDTF';		# W3CDTF: YYYY-MM-DDThh:mm:ssTZD
+					# US: mm/dd/yy
+					# UK: dd/mm/yy
 
 $update_meta_date = 0;		# Add a meta_date tag if it doesn't exist
 	# This will require that perl has write access to your story files
@@ -271,10 +272,15 @@
 
 					warn "Entries_Cache: Adding meta-tag to $file, using $meta_date $mday/$mon/$year $hour:$min:$sec\n" if ($debug == 1);
 				
-					if ($use_UK_dates eq 1) {
-						$new_story .= "$meta_date $mday/$mon/$year $hour:$min:$sec\n\n";
-					} else {
+					if ($date_format == 'W3CDTF') {
+						my $tz_offset = $timezone::offset;
+						$tz_offset =~ s/([+-]\d{2})(\d{2})/$1:$2/;
+						$new_story .= sprintf("%s %04d-%02d-%02dT%02d:%02d:%02d%s\n\n"
+								      ,$meta_date,$year,$mon,$mday,$hour,$min,$sec,$tz_offset);
+					} elsif ($date_format == 'US') {
 						$new_story .= "$meta_date $mon/$mday/$year $hour:$min:$sec\n\n";
+					} elsif ($date_format == 'UK') {
+						$new_story .= "$meta_date $mday/$mon/$year $hour:$min:$sec\n\n";
 					}
 					
 					if ( $line !~ /^\s*$/) {
@@ -319,8 +325,16 @@
 	# Convert the datestring to a time() format
 
 	# Find "Shorthand" Date
-	if ( $datestring =~ /\d\d?\/\d\d?\/\d\d\d?\d?/) {
-		if ( $use_UK_dates eq 0) {
+	if ( $datestring =~ /(\d{4})-(\d{2})-(\d{2})/) {
+		if ( $date_format == 'W3CDTF') {
+			# Use W3CDTF Formatting
+			$datestring =~ s/(\d{4})-(\d{2})-(\d{2})//;
+			$mon = $2 - 1;
+			$day = $3;
+			$year = $1;
+		}
+	} elsif ( $datestring =~ /\d\d?\/\d\d?\/\d\d\d?\d?/) {
+		if ( $date_format == 'US') {
 			# Use US Formatting
 			$datestring =~ s/(\d\d?)\/(\d\d?)\/(\d\d\d?\d?)//;
 			$mon = $1 - 1;
@@ -360,13 +374,14 @@
 		$min = $2;
 		$sec = $3;
 	}
-	
-	if ($datestring =~ s/(\d\d\d\d)//) {
-		$year = $1;
-	}
-	
-	if ($datestring =~ s/(\d\d?)//) {
-		$day = $1;
+	unless ( $date_format == 'W3CDTF') {
+		if ($datestring =~ s/(\d\d\d\d)//) {
+			$year = $1;
+		}
+
+		if ($datestring =~ s/(\d\d?)//) {
+			$day = $1;
+		}
 	}
 	
 	return timelocal($sec,$min,$hour,$day,$mon,$year);
