1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-09 04:22:30 +01:00

Auto detect first day of week for calendar

New: Calendar will use systems first day of week when displaying
This commit is contained in:
Mark McDowall 2013-10-02 12:41:21 -07:00
parent 76089b460c
commit fe5b42696d
5 changed files with 36 additions and 1 deletions

View File

@ -42,7 +42,8 @@ private Response GetStatus()
IsLinux = OsInfo.IsLinux,
IsWindows = OsInfo.IsWindows,
Branch = _configFileProvider.Branch,
Authentication = _configFileProvider.AuthenticationEnabled
Authentication = _configFileProvider.AuthenticationEnabled,
StartOfWeek = (int)OsInfo.FirstDayOfWeek
}.AsResponse();
}

View File

@ -0,0 +1,24 @@
using System;
using System.Globalization;
namespace NzbDrone.Common
{
public static class DateTimeExtensions
{
public static DateTime GetFirstDayOfWeek(this DateTime dayInWeek)
{
var defaultCultureInfo = CultureInfo.CurrentCulture;
return GetFirstDayOfWeek(dayInWeek, defaultCultureInfo);
}
public static DateTime GetFirstDayOfWeek(this DateTime dayInWeek, CultureInfo cultureInfo)
{
DayOfWeek firstDay = cultureInfo.DateTimeFormat.FirstDayOfWeek;
DateTime firstDayInWeek = dayInWeek.Date;
while (firstDayInWeek.DayOfWeek != firstDay)
firstDayInWeek = firstDayInWeek.AddDays(-1);
return firstDayInWeek;
}
}
}

View File

@ -28,5 +28,13 @@ public static bool IsWindows
return !IsLinux;
}
}
public static DayOfWeek FirstDayOfWeek
{
get
{
return DateTime.Today.GetFirstDayOfWeek().DayOfWeek;
}
}
}
}

View File

@ -66,6 +66,7 @@
<Compile Include="Composition\Container.cs" />
<Compile Include="Composition\IContainer.cs" />
<Compile Include="Composition\ContainerBuilderBase.cs" />
<Compile Include="DateTimeExtensions.cs" />
<Compile Include="EnsureThat\Ensure.cs" />
<Compile Include="EnsureThat\EnsureBoolExtensions.cs" />
<Compile Include="EnsureThat\EnsureCollectionExtensions.cs" />

View File

@ -21,6 +21,7 @@ define(
allDayDefault : false,
ignoreTimezone: false,
weekMode : 'variable',
firstDay : window.NzbDrone.ServerStatus.startOfWeek,
timeFormat : 'h(:mm)tt',
header : {
left : 'prev,next today',