Skip to content

Commit

Permalink
Merge branch 'feature/dateTime_to_set_time_(#469)' into feature/nativ…
Browse files Browse the repository at this point in the history
…e_functions_for_expressions_(#468)
  • Loading branch information
Cédric L. Charlier committed Apr 9, 2019
2 parents 656e3c3 + 5e9bd60 commit a818a8f
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,17 @@ public DateTimeToClip(string min, string max)

protected override object EvaluateDateTime(DateTime value) => (value < Min) ? Min : (value > Max) ? Max : value;
}

class DateTimeToSetTime : DateTimeToPointInTime
{
public TimeSpan Instant { get; }

public DateTimeToSetTime(string instant)
{
Instant = TimeSpan.Parse(instant);
}

protected override object EvaluateDateTime(DateTime value)
=> new DateTime(value.Year, value.Month, value.Day, Instant.Hours, Instant.Minutes, Instant.Seconds);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -130,5 +130,15 @@ public void Execute_DateTimeToPreviousYear_Valid(object value, DateTime expected
var result = function.Evaluate(value);
Assert.That(result, Is.EqualTo(expected));
}

[Test]
[TestCase("2019-03-11 12:00:00", "07:00:00", "2019-03-11 07:00:00")]
[TestCase("2019-02-11 08:45:12", "07:13:11", "2019-02-11 07:13:11")]
public void Execute_DateTimeToSetTime_Valid(object value, string instant, DateTime expected)
{
var function = new DateTimeToSetTime(instant);
var result = function.Evaluate(value);
Assert.That(result, Is.EqualTo(expected));
}
}
}
20 changes: 19 additions & 1 deletion NBi.Xml/Schema/BaseType.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,7 @@
<xs:enumeration value="empty-to-null"/>
<xs:enumeration value="null-to-empty"/>
<xs:enumeration value="null-to-value"/>
<xs:enumeration value="null-to-zero"/>
<xs:enumeration value="value-to-value"/>
<xs:enumeration value="any-to-any"/>
<xs:enumeration value="text-to-trim"/>
Expand All @@ -660,12 +661,29 @@
<xs:enumeration value="text-to-length"/>
<xs:enumeration value="text-to-html"/>
<xs:enumeration value="text-to-without-diacritics"/>
<xs:enumeration value="text-to-token-count"/>
<xs:enumeration value="text-to-without-whitespaces"/>
<xs:enumeration value="html-to-text"/>
<xs:enumeration value="date-to-age"/>
<xs:enumeration value="utc-to-local("/>
<xs:enumeration value="local-to-utc("/>
<xs:enumeration value="dateTime-to-date"/>
<xs:enumeration value="null-to-date"/>
<xs:enumeration value="null-to-date("/>
<xs:enumeration value="dateTime-to-first-of-month"/>
<xs:enumeration value="dateTime-to-last-of-month"/>
<xs:enumeration value="dateTime-to-first-of-year"/>
<xs:enumeration value="dateTime-to-last-of-year"/>
<xs:enumeration value="dateTime-to-next-day"/>
<xs:enumeration value="dateTime-to-previous-day"/>
<xs:enumeration value="dateTime-to-next-month"/>
<xs:enumeration value="dateTime-to-previous-month"/>
<xs:enumeration value="dateTime-to-next-year"/>
<xs:enumeration value="dateTime-to-previous-year"/>
<xs:enumeration value="dateTime-to-set-time("/>
<xs:enumeration value="numeric-to-round("/>
<xs:enumeration value="numeric-to-floor"/>
<xs:enumeration value="numeric-to-ceiling"/>
<xs:enumeration value="numeric-to-integer"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="not-native-transformation-type">
Expand Down

0 comments on commit a818a8f

Please sign in to comment.