本文整理汇总了C#中Date.AddDays方法的典型用法代码示例。如果您正苦于以下问题:C# Date.AddDays方法的具体用法?C# Date.AddDays怎么用?C# Date.AddDays使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Date
的用法示例。
在下文中一共展示了Date.AddDays方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CanAddNegativeDays
public void CanAddNegativeDays()
{
var dt = new Date(2000, 1, 1);
var actual = dt.AddDays(-1);
var expected = new Date(1999, 12, 31);
Assert.Equal(expected, actual);
}
示例2: CanAddZeroDays
public void CanAddZeroDays()
{
var dt = new Date(2000, 1, 1);
var actual = dt.AddDays(0);
var expected = new Date(2000, 1, 1);
Assert.Equal(expected, actual);
}
示例3: CanAddPositiveDays
public void CanAddPositiveDays()
{
var dt = new Date(2000, 1, 1);
var actual = dt.AddDays(1);
var expected = new Date(2000, 1, 2);
Assert.Equal(expected, actual);
}
示例4: 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;
}
}