相关疑难解决方法(0)

在NodaTime中获取夏令时开始和结束时间

如何使用Noda Time获取夏令时的开始和结束日期?下面的功能完成了这个任务,但它非常笨拙,并且正在寻求一个更简单的解决方案.

/// <summary>
/// Gets the start and end of daylight savings time in a given time zone
/// </summary>
/// <param name="tz">The time zone in question</param>
/// <returns>A tuple indicating the start and end of DST</returns>
/// <remarks>Assumes this zone has daylight savings time</remarks>
private Tuple<LocalDateTime, LocalDateTime> GetZoneStartAndEnd(DateTimeZone tz)
{
    int thisYear = TimeUtils.SystemLocalDateTime.Year; // Get the year of the current LocalDateTime

    // Get January 1, midnight, of this year and next year.
    var yearStart = new LocalDateTime(thisYear, …
Run Code Online (Sandbox Code Playgroud)

c# date dst nodatime

10
推荐指数
1
解决办法
4135
查看次数

标签 统计

c# ×1

date ×1

dst ×1

nodatime ×1