Skip to content

Commit

Permalink
Removed CurrentTimezone for now. All tests except one trying to gener…
Browse files Browse the repository at this point in the history
…ate `Sat Sep 13 275760 00:00:00 GMT+1000 (Local Standard Time)` (WTF?) pass.

Incorporated Fix nilproject#133 too
  • Loading branch information
jsobell committed May 5, 2018
1 parent 96f372d commit 99d4e83
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 12 deletions.
2 changes: 2 additions & 0 deletions Comparisons/dates.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
new Date(1970, 0, 100000001, 0, 0, 0, 0)

new Date("2010-08-30T00:00:00-0400")

new Date("2010-08-30T00:00:00")
Expand Down
1 change: 1 addition & 0 deletions Comparisons/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

[DATE].getDate()
[DATE].getDay()
[DATE].getYear()
[DATE].getFullYear()
[DATE].getHours()
[DATE].getMilliseconds()
Expand Down
6 changes: 5 additions & 1 deletion IntegrationTests/BaseLibrary/DateTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ public void NewDateShouldContainCurrentTime()
Assert.AreEqual(date.getSeconds(), dateTime.Second);
}

/*
[TestMethod]
public void ShouldCorrectHandleSwitchFromDstToStandard_SydneyTimeZone()
{
Expand All @@ -105,13 +106,15 @@ public void ShouldCorrectHandleSwitchFromDstToStandard_SydneyTimeZone()
Assert.IsTrue(d2.ToString().StartsWith("Sun Mar 26 2000 02:00:00 GMT+1000"));
Assert.IsTrue(d3.ToString().StartsWith("Sun Mar 26 2000 03:00:00 GMT+1000"));
}
*/
/*
[TestMethod]
public void ShouldCorrectHandleSwitchFromDstToStandard_UKTimeZone()
{
var timezone = TimeZoneInfo.GetSystemTimeZones()
.First(x => x.Id.Contains("GMT Standard Time"));
Date.CurrentTimeZone = timezone;
//Date.CurrentTimeZone = timezone;
var d1 = new Date(new Arguments { 972779400000 });
var d2 = new Date(new Arguments { 972781200000 });
Expand All @@ -121,6 +124,7 @@ public void ShouldCorrectHandleSwitchFromDstToStandard_UKTimeZone()
Assert.IsTrue(d2.ToString().StartsWith("Sun Oct 29 2000 01:00:00 GMT+0000"));
Assert.IsTrue(d3.ToString().StartsWith("Sun Oct 29 2000 02:00:00 GMT+0000"));
}
*/



Expand Down
13 changes: 3 additions & 10 deletions NiL.JS/BaseLibrary/Date.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,7 @@ namespace NiL.JS.BaseLibrary
#endif
public sealed class Date
{
private static TimeZoneInfo s_currentTimeZone = TimeZoneInfo.Local;

[Hidden]
public static TimeZoneInfo CurrentTimeZone
{
get => s_currentTimeZone;
set => s_currentTimeZone = value ?? throw new ArgumentNullException(nameof(value));
}
[Hidden] public static TimeZoneInfo CurrentTimeZone = TimeZoneInfo.Local;

private const long _timeAccuracy = TimeSpan.TicksPerMillisecond;
private const long _unixTimeBase = 62135596800000;
Expand Down Expand Up @@ -286,7 +279,7 @@ public JSValue getTimezoneOffset()
[DoNotEnumerate]
public JSValue getYear()
{
return getFullYear();
return (int)getFullYear() - 1900;
}

[DoNotEnumerate]
Expand Down Expand Up @@ -835,7 +828,7 @@ private string stringifyTime(bool withTzo, bool rfc1123)
+ getMinutesImpl(withTzo).ToString("00:")
+ getSecondsImpl().ToString("00")
+ " GMT" + (withTzo
? (offset.Ticks > 0 ? "+" : "") + (offset.Hours * 100 + offset.Minutes).ToString("0000") + " (" +
? (offset.Ticks >= 0 ? "+" : "") + (offset.Hours * 100 + offset.Minutes).ToString("0000") + " (" +
timeName + ")"
: "");
return res;
Expand Down
4 changes: 3 additions & 1 deletion NiL.JS/Statements/CodeBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,9 @@ public override void Decompose(ref CodeNode self)

for (int i = 0; i < _lines.Length; i++)
{
_lines[i].Decompose(ref _lines[i]);
var line = _lines[i];
line.Decompose(ref line);
_lines[i] = line;
}
}

Expand Down

0 comments on commit 99d4e83

Please sign in to comment.