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:
parent
76089b460c
commit
fe5b42696d
@ -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();
|
||||
|
||||
}
|
||||
|
24
NzbDrone.Common/DateTimeExtensions.cs
Normal file
24
NzbDrone.Common/DateTimeExtensions.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
@ -28,5 +28,13 @@ public static bool IsWindows
|
||||
return !IsLinux;
|
||||
}
|
||||
}
|
||||
|
||||
public static DayOfWeek FirstDayOfWeek
|
||||
{
|
||||
get
|
||||
{
|
||||
return DateTime.Today.GetFirstDayOfWeek().DayOfWeek;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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" />
|
||||
|
@ -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',
|
||||
|
Loading…
Reference in New Issue
Block a user