Passing and returning DateTimeOffset to Engine #1777
Unanswered
denisbredikhin
asked this question in
Q&A
Replies: 1 comment
-
JavaScript dates don't have time zone information. You can always cast the resulting DateTime to DateTimeOffset which will have offset of zero. You could also experiment with building a custom JsValue type but there might be some bumps on the road. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
In our application, end-users can write scripts in one of the two languages: JS and C#. For JS, we are using Jint, and for C#, we use Roslyn.
We want to achieve that the results of the execution are consistent, doesn't matter which language is used.
Quite often, as a parameter of the script, we pass the DateTimeOffset value. This gives a problem because if we somehow process the DateTimeOffset input in the C# script, we get back DateTimeOffset, while if we do this with Jint, we get back DateTime.
I've written a small unit test (added to InteropTests), which should pass to be able to achieve what we want:
Can you please tell me if this is something that can be added to Jint? Maybe it is already possible with some flags or with the import of some JavaScript libraries?
Beta Was this translation helpful? Give feedback.
All reactions