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


C# Date.AddMonths方法代码示例

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


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

示例1: CanAddNegativeMonths_FromDay31_ToDay30

 public void CanAddNegativeMonths_FromDay31_ToDay30()
 {
     var dt = new Date(2000, 5, 31);
     var actual = dt.AddMonths(-1);
     var expected = new Date(2000, 4, 30);
     Assert.Equal(expected, actual);
 }
开发者ID:kronic,项目名称:corefxlab,代码行数:7,代码来源:DateMathTests.cs

示例2: CanAddNegativeMonths_FromDay31_ToDay28

 public void CanAddNegativeMonths_FromDay31_ToDay28()
 {
     var dt = new Date(2001, 3, 31);
     var actual = dt.AddMonths(-1);
     var expected = new Date(2001, 2, 28);
     Assert.Equal(expected, actual);
 }
开发者ID:kronic,项目名称:corefxlab,代码行数:7,代码来源:DateMathTests.cs

示例3: CanAddNegativeMonths

 public void CanAddNegativeMonths()
 {
     var dt = new Date(2000, 1, 1);
     var actual = dt.AddMonths(-1);
     var expected = new Date(1999, 12, 1);
     Assert.Equal(expected, actual);
 }
开发者ID:kronic,项目名称:corefxlab,代码行数:7,代码来源:DateMathTests.cs

示例4: CanAddPositiveMonths

 public void CanAddPositiveMonths()
 {
     var dt = new Date(2000, 1, 1);
     var actual = dt.AddMonths(1);
     var expected = new Date(2000, 2, 1);
     Assert.Equal(expected, actual);
 }
开发者ID:GrimDerp,项目名称:corefxlab,代码行数:7,代码来源:DateMathTests.cs

示例5: CanAddPositiveMonths_FromDay30_ToDay28

 public void CanAddPositiveMonths_FromDay30_ToDay28()
 {
     var dt = new Date(2000, 11, 30);
     var actual = dt.AddMonths(3);
     var expected = new Date(2001, 2, 28);
     Assert.Equal(expected, actual);
 }
开发者ID:GrimDerp,项目名称:corefxlab,代码行数:7,代码来源:DateMathTests.cs

示例6: CanAddPositiveMonths_FromDay31_ToDay29

 public void CanAddPositiveMonths_FromDay31_ToDay29()
 {
     var dt = new Date(2000, 1, 31);
     var actual = dt.AddMonths(1);
     var expected = new Date(2000, 2, 29);
     Assert.Equal(expected, actual);
 }
开发者ID:GrimDerp,项目名称:corefxlab,代码行数:7,代码来源:DateMathTests.cs

示例7: CanAddZeroMonths

 public void CanAddZeroMonths()
 {
     var dt = new Date(2000, 1, 1);
     var actual = dt.AddMonths(0);
     var expected = new Date(2000, 1, 1);
     Assert.Equal(expected, actual);
 }
开发者ID:GrimDerp,项目名称:corefxlab,代码行数:7,代码来源:DateMathTests.cs

示例8: Test_CalculatePrintNumber_02

 public static void Test_CalculatePrintNumber_02(Print print, string directory, Date date, int nb)
 {
     string traceFile = zPath.Combine(zPath.Combine(directory, @"Print\CalculatePrintDateNumber"), string.Format("Print_{0}_Number.txt", print.Name));
     Trace.WriteLine("print {0} frequency {1} calculate number from date {2:dd-MM-yyyy} nb {3} trace file \"{4}\"", print.Name, print.Frequency, date, nb, zPath.GetFileName(traceFile));
     //Trace.CurrentTrace.DisableBaseLog();
     //Trace.CurrentTrace.DisableTraceView = true;
     //Trace.CurrentTrace.AddTraceFile(traceFile, LogOptions.RazLogFile);
     Trace.CurrentTrace.AddOnWrite("Test_CalculatePrintNumber_02", WriteToFile.Create(traceFile, FileOption.RazFile).Write);
     try
     {
         Trace.WriteLine("print {0} frequency {1} calculate number from date {2:dd-MM-yyyy} nb {3}", print.Name, print.Frequency, date, nb);
         Trace.WriteLine();
         if (print.Frequency == PrintFrequency.Daily)
         {
             for (int i = 0; i < nb; i++)
             {
                 PrintIssue issue = print.NewPrintIssue(date);
                 int number = issue.PrintNumber;
                 Trace.WriteLine("{0:yyyy-MM-dd ddd} {1}", issue.Date, number);
                 date = date.AddDays(1);
             }
         }
         else if (print.Frequency == PrintFrequency.Weekly)
         {
             for (int i = 0; i < nb; i++)
             {
                 PrintIssue issue = print.NewPrintIssue(date);
                 int number = issue.PrintNumber;
                 Trace.WriteLine("{0:yyyy-MM-dd ddd} {1}", issue.Date, number);
                 date = date.AddDays(7);
             }
         }
         else if (print.Frequency == PrintFrequency.Monthly)
         {
             for (int i = 0; i < nb; i++)
             {
                 PrintIssue issue = print.NewPrintIssue(date);
                 int number = issue.PrintNumber;
                 Trace.WriteLine("{0:yyyy-MM-dd ddd} {1}", issue.Date, number);
                 date = date.AddMonths(1);
             }
         }
         else if (print.Frequency == PrintFrequency.Bimonthly || print.Frequency == PrintFrequency.Quarterly)
         {
             int lastNumber = 0;
             for (int i = 0; i < nb; )
             {
                 PrintIssue issue = print.NewPrintIssue(date);
                 int number = issue.PrintNumber;
                 if (number != lastNumber)
                 {
                     Trace.WriteLine("{0:yyyy-MM-dd ddd} {1}", issue.Date, number);
                     lastNumber = number;
                     i++;
                 }
                 date = date.AddMonths(1);
             }
         }
     }
     finally
     {
         //Trace.CurrentTrace.EnableBaseLog();
         //Trace.CurrentTrace.RemoveTraceFile(traceFile);
         Trace.CurrentTrace.RemoveOnWrite("Test_CalculatePrintNumber_02");
         Trace.CurrentTrace.DisableViewer = false;
     }
 }
开发者ID:labeuze,项目名称:source,代码行数:67,代码来源:Test_Unit_Print.cs


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