Toby Inkster avatar Toby Inkster committed 3870cbf

Support XSD 1.1 features for datetimes: explicitTimezone facet, and DateTimeStamp type

Comments (0)

Files changed (1)

 		delete $o->{length};
 		"!!1"
 	},
+	explicitTimezone => sub {
+		my ($o, $var) = @_;
+		return unless exists $o->{explicitTimezone};
+		my $etz = delete $o->{explicitTimezone};
+		return sprintf('%s =~ m/(?:Z|(?:[+-]\d{2}:?\d{2}))$/xism', $var)
+			if lc($etz) eq 'required';
+		return sprintf('%s !~ m/(?:Z|(?:[+-]\d{2}:?\d{2}))$/xism', $var)
+			if lc($etz) eq 'prohibited';
+		return '!!1'
+			if lc($etz) eq 'optional';
+		croak "explicitTimezone facet expected to be 'required', 'prohibited' or 'optional'"
+	},
 	maxLengthQName => sub {
 		my ($o, $var) = @_;
 		return unless exists $o->{maxLength};
 	__PACKAGE__->add_type($type);
 	
 	facet(
-		qw( pattern whiteSpace enumeration maxInclusiveDT maxExclusiveDT minInclusiveDT minExclusiveDT ),
+		qw( pattern whiteSpace enumeration maxInclusiveDT maxExclusiveDT minInclusiveDT minExclusiveDT explicitTimezone ),
 		$type,
 	);
 	
 	NonNegativeInteger PositiveInteger UnsignedLong UnsignedInt
 	UnsignedShort UnsignedByte Duration DateTime Time Date GYearMonth
 	GYear GMonthDay GDay GMonth
+	DateTimeStamp
 );
 
 our @EXPORT_OK = qw( dt_cmp dur_cmp dt_parse dur_parse );
 );
 
 dt_maker(
+	DateTimeStamp => qr{^
+		(-?[0-9]{4,})
+		-
+		([0-9]{2})
+		-
+		([0-9]{2})
+		T
+		([0-9]{2})
+		:
+		([0-9]{2})
+		:
+		([0-9]{2}(?:\.[0-9]+)?)
+		(Z | (?: [+-]\d{2}:?\d{2} ))
+	$}xism,
+	qw( year month day hour minute second time_zone ),
+);
+
+dt_maker(
 	Time => qr{^
 		([0-9]{2})
 		:
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.