当前位置: 首页>>代码示例>>C#>>正文


C# DayOfWeek.GetValueOrDefault方法代码示例

本文整理汇总了C#中DayOfWeek.GetValueOrDefault方法的典型用法代码示例。如果您正苦于以下问题:C# DayOfWeek.GetValueOrDefault方法的具体用法?C# DayOfWeek.GetValueOrDefault怎么用?C# DayOfWeek.GetValueOrDefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DayOfWeek的用法示例。


在下文中一共展示了DayOfWeek.GetValueOrDefault方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: EndOfWeek

 /// <summary>
 /// Returns the end of week from the supplied date
 /// </summary>
 public static DateTime EndOfWeek(this DateTime instance, DayOfWeek? on = null)
 {
     DayOfWeek day = on.GetValueOrDefault(DayOfWeek.Saturday);
     int days = day - instance.DayOfWeek;
     if (days < 0) days += 7;
     days = days * -1;
     return new DateTime(instance.Year, instance.Month, instance.Day, 23, 59, 59, 999).AddDays(days);
 }
开发者ID:ExtendType,项目名称:OfDateTime,代码行数:11,代码来源:Extensions.cs

示例2: StartOfWeek

 /// <summary>
 /// Returns the start of week from the supplied date
 /// </summary>
 public static DateTime StartOfWeek(this DateTime instance, DayOfWeek? on = null)
 {
     DayOfWeek day = on.GetValueOrDefault(DayOfWeek.Sunday);
     int days = instance.DayOfWeek - day;
     if (days < 0) days += 7;
     days = days * -1;
     return new DateTime(instance.Year, instance.Month, instance.Day, 0, 0, 0, 0).AddDays(days);
 }
开发者ID:ExtendType,项目名称:OfDateTime,代码行数:11,代码来源:Extensions.cs

示例3: GetWeekOfYearRuleKind

        /// <summary>
        /// <paramref name="weekRule"/>, <paramref name="firstDayOfWeek"/>에 해당하는 <see cref="WeekOfYearRuleKind"/>를 판단합니다.
        /// </summary>
        /// <param name="weekRule">한해의 첫주를 산정하는 규칙</param>
        /// <param name="firstDayOfWeek">한주의 첫번째 요일</param>
        public static WeekOfYearRuleKind GetWeekOfYearRuleKind(CalendarWeekRule? weekRule = null,
                                                               DayOfWeek? firstDayOfWeek = null) {
            if(weekRule.GetValueOrDefault(DateTimeFormatInfo.CurrentInfo.CalendarWeekRule) == CalendarWeekRule.FirstFourDayWeek &&
               firstDayOfWeek.GetValueOrDefault(DateTimeFormatInfo.CurrentInfo.FirstDayOfWeek) == DayOfWeek.Monday)
                return WeekOfYearRuleKind.Iso8601;

            return WeekOfYearRuleKind.Calendar;
        }
开发者ID:debop,项目名称:NFramework,代码行数:13,代码来源:WeekTool.cs


注:本文中的DayOfWeek.GetValueOrDefault方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。