Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make TimeZone changeable #191

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

masaedw
Copy link

@masaedw masaedw commented Apr 20, 2017

TimeZone used by os.time () is hard coded in TimeZoneInfo.LocalTime, but by applying this pull request, it can be changed for each Script object.

ex)

Script S = new Script();
// set your preferred TimeZoneInfo
S.Options.LocalTimeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById("Central European Standard Time");
// You can get local time different from the system time zone
DynValue res = S.DoString("return os.date(\"%Y-%m-%d %H:%M:%S\")");

@LimpingNinja LimpingNinja self-assigned this Jan 9, 2020
@LimpingNinja LimpingNinja self-requested a review January 15, 2020 23:51
Copy link
Contributor

@LimpingNinja LimpingNinja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay, we've got new maintainers now and are culling the backlog.

@@ -123,7 +123,9 @@ public static DynValue date(ScriptExecutionContext executionContext, CallbackArg

try
{
reference = TimeZoneInfo.ConvertTimeFromUtc(reference, TimeZoneInfo.Local);
TimeZoneInfo localTimeZoneInfo = executionContext.OwnerScript.Options.LocalTimeZoneInfo ?? TimeZoneInfo.Local;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logic needs to be added to:

src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/OsTimeModule.cs
src/Unity/MoonSharp/Assets/Plugins/MoonSharp/Interpreter/CoreLib/OsTimeModule.cs

If adding this in to the current system; as we push to clean this up it will change, but for now this PR will be accepted if the additional locations are updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants