Minor additions to datetime units
This commit is contained in:
parent
822771afe8
commit
628cb0c807
|
@ -4,13 +4,12 @@ type expressionValue = ExpressionValue.expressionValue
|
|||
let dateDispatch = (call: ExpressionValue.functionCall, _: DistributionOperation.env): option<
|
||||
result<expressionValue, QuriSquiggleLang.Reducer_ErrorValue.errorValue>,
|
||||
> => {
|
||||
open ExpressionValue
|
||||
switch call {
|
||||
| ("toString", [EvDate(t)]) => EvString(DateTime.Date.toString(t))->Ok->Some
|
||||
| ("makeDateFromYear", [EvNumber(year)]) =>
|
||||
switch DateTime.Date.makeFromYear(year) {
|
||||
| Ok(t) => EvDate(t)->Ok->Some
|
||||
| Error(e) => RETodo(e)->Error->Some
|
||||
| Error(e) => Reducer_ErrorValue.RETodo(e)->Error->Some
|
||||
}
|
||||
| ("dateFromNumber", [EvNumber(f)]) => EvDate(DateTime.Date.fromFloat(f))->Ok->Some
|
||||
| ("toNumber", [EvDate(f)]) => EvNumber(DateTime.Date.toFloat(f))->Ok->Some
|
||||
|
@ -31,10 +30,14 @@ let durationDispatch = (call: ExpressionValue.functionCall, _: DistributionOpera
|
|||
> => {
|
||||
switch call {
|
||||
| ("toString", [EvTimeDuration(t)]) => EvString(DateTime.Duration.toString(t))->Ok->Some
|
||||
| ("hours", [EvNumber(f)]) => EvTimeDuration(DateTime.Duration.fromHours(f))->Ok->Some
|
||||
| ("minutes", [EvNumber(f)]) => EvTimeDuration(DateTime.Duration.fromMinutes(f))->Ok->Some
|
||||
| ("fromUnit_minutes", [EvNumber(f)]) => EvTimeDuration(DateTime.Duration.fromMinutes(f))->Ok->Some
|
||||
| ("hours", [EvNumber(f)]) => EvTimeDuration(DateTime.Duration.fromHours(f))->Ok->Some
|
||||
| ("fromUnit_hours", [EvNumber(f)]) => EvTimeDuration(DateTime.Duration.fromHours(f))->Ok->Some
|
||||
| ("days", [EvNumber(f)]) => EvTimeDuration(DateTime.Duration.fromDays(f))->Ok->Some
|
||||
| ("fromUnit_days", [EvNumber(f)]) => EvTimeDuration(DateTime.Duration.fromDays(f))->Ok->Some
|
||||
| ("years", [EvNumber(f)]) => EvTimeDuration(DateTime.Duration.fromYears(f))->Ok->Some
|
||||
| ("fromUnit_years", [EvNumber(f)]) => EvTimeDuration(DateTime.Duration.fromYears(f))->Ok->Some
|
||||
| ("toHours", [EvTimeDuration(f)]) => EvNumber(DateTime.Duration.toHours(f))->Ok->Some
|
||||
| ("toMinutes", [EvTimeDuration(f)]) => EvNumber(DateTime.Duration.toMinutes(f))->Ok->Some
|
||||
| ("toDays", [EvTimeDuration(f)]) => EvNumber(DateTime.Duration.toDays(f))->Ok->Some
|
||||
|
|
Loading…
Reference in New Issue
Block a user