public void HandleDateParam() { // Brian: Not sure tha these tests SHOULD pass... // a time component on the Date? var p1 = new DateValue(new DateTimeOffset(1972, 11, 30, 15, 20, 49, TimeSpan.Zero)); Assert.AreEqual("1972-11-30", p1.ToString()); // we can parse a valid FHIR datetime and strip the time part off // (but it must be a valid FHIR datetime) var p2 = DateValue.Parse("1972-11-30T18:45:36Z"); Assert.AreEqual("1972-11-30", p2.ToString()); var crit = Criterium.Parse("paramX=1972-11-30"); var p3 = ((UntypedValue)crit.Operand).AsDateValue(); Assert.AreEqual("1972-11-30", p3.Value); try { // Test with an invalid FHIR datetime (no timezone specified) var p4 = DateValue.Parse("1972-11-30T18:45:36"); Assert.Fail("The datetime [1972-11-30T18:45:36] does not have a timezone, hence should fail parsing as a datevalue (via fhirdatetime)"); } catch (ArgumentException) { } }
private BsonValue MapExpression(DateValue dateValue) { return BsonValue.Create(dateValue.Value); }
public DateValue AsDateValue() { return(DateValue.Parse(Value)); }