Skip to content

Commit

Permalink
std: Add 'into::dateTime'
Browse files Browse the repository at this point in the history
  • Loading branch information
PaddiM8 committed Nov 23, 2024
1 parent 48095eb commit 020c681
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Std/Into.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
Expand Down Expand Up @@ -88,6 +89,11 @@ void BuildRow(IEnumerable<string> cells)
public static RuntimeError Error(RuntimeObject value)
=> new(value);

/// <param name="unixTimestamp">A Unix timestamp (in seconds)</param>
[ElkFunction("dateTime")]
public static RuntimeDateTime ToDateTime(RuntimeInteger unixTimestamp)
=> new(DateTimeOffset.FromUnixTimeSeconds(unixTimestamp.Value).DateTime);

/// <param name="value">Value that should be cast</param>
[ElkFunction("dict")]
public static RuntimeDictionary ToDictionary(RuntimeObject? value = null)
Expand Down
1 change: 1 addition & 0 deletions src/Vm/InstructionGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1302,6 +1302,7 @@ private void EmitProgramCall(CallExpr expr, bool isMaybeRoot = false)
RedirectionKind.Error => ProgramCallProps.RedirectError,
_ => ProgramCallProps.None,
};

// Environment variables
foreach (var (key, value) in expr.EnvironmentVariables)
{
Expand Down

0 comments on commit 020c681

Please sign in to comment.