Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
jas-valgotar committed Sep 24, 2024
1 parent bbe833d commit e82c913
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ internal static partial class Library
/// </summary>
public static readonly TexlFunction DistinctInterpreterFunction = new DistinctFunction();

internal static readonly DateTime _epoch = new DateTime(1899, 12, 30, 0, 0, 0, 0);
internal static readonly DateTime _epoch = new DateTime(1899, 12, 30, 0, 0, 0, 0, DateTimeKind.Utc);

// Helper to get a service or fallback to a default if the service is missing.
private static T GetService<T>(this IServiceProvider services, T defaultService)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,21 @@ public async Task BasicEvaluation()
Assert.Equal(5.0, result.ToObject());
}

[Fact]
public async Task TestDecimalToDateTimeCoercion()
{
// Per expression.
var engine = new RecalcEngine();
var rc = new RuntimeConfig();
rc.SetTimeZone(TimeZoneInfo.Utc);

var res = await engine.EvalAsync("If(false, DateTime(1899, 12, 30, 0, 0, 0, 0), 0)", CancellationToken.None, runtimeConfig: rc);

var dt = res.ToObject();

Assert.Equal(DateTimeKind.Utc, ((DateTime)dt).Kind);
}

[Fact]
public async Task BasicDirectEvalFunc()
{
Expand Down

0 comments on commit e82c913

Please sign in to comment.