diff --git a/stix2/patterns.py b/stix2/patterns.py index 7858146..03b7657 100644 --- a/stix2/patterns.py +++ b/stix2/patterns.py @@ -24,7 +24,7 @@ class TimestampConstant(_Constant): self.value = value def __str__(self): - return "'%s'" % escape_quotes_and_backslashes(self.value) + return "t'%s'" % escape_quotes_and_backslashes(self.value) class IntegerConstant(_Constant): diff --git a/stix2/test/test_pattern_expressions.py b/stix2/test/test_pattern_expressions.py index e806aa6..0db1083 100644 --- a/stix2/test/test_pattern_expressions.py +++ b/stix2/test/test_pattern_expressions.py @@ -170,3 +170,8 @@ def test_set_op(): exp = stix2.ObservationExpression(stix2.IsSubsetComparisonExpression("network-traffic:dst_ref.value", "2001:0db8:dead:beef:0000:0000:0000:0000/64")) assert str(exp) == "[network-traffic:dst_ref.value ISSUBSET '2001:0db8:dead:beef:0000:0000:0000:0000/64']" + + +def test_timestamp(): + ts = stix2.TimestampConstant('2014-01-13T07:03:17Z') + assert str(ts) == "t'2014-01-13T07:03:17Z'"