mirror of https://github.com/abpframework/abp.git
2 changed files with 28 additions and 19 deletions
@ -0,0 +1,27 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using TimeZoneConverter; |
|||
|
|||
namespace Volo.Abp.Timing; |
|||
|
|||
public static class TimeZoneHelper |
|||
{ |
|||
public static List<NameValue> GetTimezones(List<NameValue> timezones) |
|||
{ |
|||
return timezones |
|||
.OrderBy(x => x.Name) |
|||
.Select(x => new NameValue( $"{x.Name} ({GetTimezoneOffset(TZConvert.GetTimeZoneInfo(x.Name))})", x.Name)) |
|||
.ToList(); |
|||
} |
|||
|
|||
public static string GetTimezoneOffset(TimeZoneInfo timeZoneInfo) |
|||
{ |
|||
if (timeZoneInfo.BaseUtcOffset < TimeSpan.Zero) |
|||
{ |
|||
return "-" + timeZoneInfo.BaseUtcOffset.ToString(@"hh\:mm"); |
|||
} |
|||
|
|||
return "+" + timeZoneInfo.BaseUtcOffset.ToString(@"hh\:mm"); |
|||
} |
|||
} |
|||
Loading…
Reference in new issue