Skip to content

Commit

Permalink
Date corrections for nilproject#114
Browse files Browse the repository at this point in the history
  • Loading branch information
jsobell committed Apr 23, 2018
1 parent 3133a17 commit e677690
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions NiL.JS/BaseLibrary/Date.cs
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ private JSValue toIsoString()
if ((_time + _timeZoneOffset) > 8702135600400000 || (_time + _timeZoneOffset) < -8577864403200000 || _error)
ExceptionHelper.Throw(new RangeError("Invalid time value"));

var y = getYearImpl(true);
var y = getYearImpl(false);

return y +
"-" + (this.getMonthImpl(false) + 1).ToString("00") +
Expand All @@ -732,10 +732,19 @@ private string stringifyDate(bool withTzo)
return "Invalid date";

var res =
daysOfWeek[(getDayImpl(withTzo) + 6) % 7] + " "
+ months[getMonthImpl(withTzo)]
+ " " + getDateImpl(withTzo).ToString("00") + " "
+ getYearImpl(withTzo);
withTzo
? daysOfWeek[(getDayImpl(true) + 6) % 7] + " "
+ months[getMonthImpl(true)]
+ " "
+ getDateImpl(true).ToString("00")
+ " "
+ getYearImpl(true)
: daysOfWeek[(getDayImpl(false) + 6) % 7] + ", "
+ getDateImpl(false).ToString("00")
+ " "
+ months[getMonthImpl(false)]
+ " "
+ getYearImpl(false);
return res;
}

Expand All @@ -746,11 +755,14 @@ private string stringifyTime(bool withTzo)

var offset = new TimeSpan(_timeZoneOffset * _timeAccuracy);
var timeName = CurrentTimeZone.IsDaylightSavingTime(new DateTimeOffset(_time * _timeAccuracy, offset)) ? TimeZoneInfo.Local.DaylightName : TimeZoneInfo.Local.StandardName;
var res =
getHoursImpl(withTzo).ToString("00:")
+ getMinutesImpl(withTzo).ToString("00:")
+ getSecondsImpl().ToString("00")
+ " GMT" + (offset.Ticks > 0 ? "+" : "") + (offset.Hours * 100 + offset.Minutes).ToString("0000") + " (" + timeName + ")";
var res = getHoursImpl(withTzo).ToString("00:")
+ getMinutesImpl(withTzo).ToString("00:")
+ getSecondsImpl().ToString("00")
+ " GMT"
+ (withTzo
? (offset.Ticks > 0 ? "+" : "") + (offset.Hours * 100 + offset.Minutes).ToString("0000") +
" (" + timeName + ")"
: "");
return res;
}

Expand Down

0 comments on commit e677690

Please sign in to comment.