Skip to content

Make TimeZone changeable#191

Open
masaedw wants to merge 4 commits into
moonsharp-devs:legacy/2.0from
masaedw:configure-timezone
Open

Make TimeZone changeable#191
masaedw wants to merge 4 commits into
moonsharp-devs:legacy/2.0from
masaedw:configure-timezone

Conversation

@masaedw

@masaedw masaedw commented Apr 20, 2017

Copy link
Copy Markdown

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

@LimpingNinja LimpingNinja left a comment

Copy link
Copy Markdown
Contributor

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.

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

Copy link
Copy Markdown
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.

@Benjamin-Dobell
Benjamin-Dobell changed the base branch from master to legacy/2.0 March 3, 2026 07:00
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