本文整理汇总了C#中System.Date类的典型用法代码示例。如果您正苦于以下问题:C# Date类的具体用法?C# Date怎么用?C# Date使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Date类属于System命名空间,在下文中一共展示了Date类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Comparison
public void Comparison()
{
var firstDate = new Date(2011, 1, 1);
var sameAsFirstDate = new Date(2011, 1, 1);
var laterDate = new Date(2011, 1, 2);
Expect(firstDate < laterDate);
Expect(laterDate < firstDate, Is.False);
Expect(firstDate > laterDate, Is.False);
Expect(laterDate > firstDate);
Expect(firstDate <= laterDate);
Expect(laterDate <= firstDate, Is.False);
Expect(firstDate >= laterDate, Is.False);
Expect(laterDate >= firstDate);
Expect(firstDate <= sameAsFirstDate);
Expect(firstDate >= sameAsFirstDate);
Expect(firstDate < sameAsFirstDate, Is.False);
Expect(firstDate > sameAsFirstDate, Is.False);
Expect(firstDate, Is.EqualTo(sameAsFirstDate));
Expect(firstDate.Equals(sameAsFirstDate));
}
开发者ID:phoenixwebgroup,项目名称:DotNetExtensions,代码行数:26,代码来源:DateTests.cs
示例2: GetMonthlyPrintNumber
public static int GetMonthlyPrintNumber(Date date, int refNumber, Date refDate, Month noPrintMonths, Dictionary<int, int> noPrintDates, Dictionary<int, int> noPrintNumbers)
{
int no = refNumber;
Date date2 = refDate;
while (date > date2)
{
date2 = date2.AddMonths(1);
Month month = zdate.GetMonth(date2.Month);
if ((noPrintMonths & month) != month && !noPrintDates.ContainsKey(date2.AbsoluteDay))
{
do
{
no++;
} while (noPrintNumbers.ContainsKey(no));
}
}
while (date < date2)
{
Month month = zdate.GetMonth(date2.Month);
if ((noPrintMonths & month) != month && !noPrintDates.ContainsKey(date2.AbsoluteDay))
{
do
{
no--;
} while (noPrintNumbers.ContainsKey(no));
}
date2 = date2.AddMonths(-1);
}
return no;
}
开发者ID:labeuze,项目名称:source,代码行数:30,代码来源:zprint.cs
示例3: Construction
public Construction(BuildingType type, Settlement location, Date today)
{
_type = type;
_location = location;
_startDate = today;
//_resourceRequirements = _type.RequirementsFor(location);
}
开发者ID:ndech,项目名称:Alpha,代码行数:7,代码来源:Construction.cs
示例4: Contains
/// <summary>
/// Contains 目标时刻是否在时间范围内
/// </summary>
public bool Contains(Date target)
{
bool bStart = this._start.CompareTo(target) <= 0;
bool bEnd = this._end.CompareTo(target) >= 0;
return bStart && bEnd;
}
开发者ID:summer-breeze,项目名称:ChengGouHui,代码行数:10,代码来源:DateScope.cs
示例5: Main
static void Main(string[] args)
{
Date aDate = new Date();
Date anotherDate = new Date(2003, 11, 5);
Console.WriteLine("aDate:\n" + aDate);
Console.WriteLine("anotherDate:\n" + anotherDate);
}
开发者ID:reshadn,项目名称:AcademicProgrammingProjects,代码行数:7,代码来源:Program.cs
示例6: EmbeddingOfInstanceOfCustomValueTypeWithFieldsIsCorrect
public virtual void EmbeddingOfInstanceOfCustomValueTypeWithFieldsIsCorrect()
{
// Arrange
var date = new Date(2015, 12, 29);
const string updateCode = "date.Day += 2;";
const string input1 = "date.Year";
const int targetOutput1 = 2015;
const string input2 = "date.Month";
const int targetOutput2 = 12;
const string input3 = "date.Day";
const int targetOutput3 = 31;
// Act
int output1;
int output2;
int output3;
using (var jsEngine = CreateJsEngine())
{
jsEngine.EmbedHostObject("date", date);
jsEngine.Execute(updateCode);
output1 = jsEngine.Evaluate<int>(input1);
output2 = jsEngine.Evaluate<int>(input2);
output3 = jsEngine.Evaluate<int>(input3);
}
// Assert
Assert.AreEqual(targetOutput1, output1);
Assert.AreEqual(targetOutput2, output2);
Assert.AreEqual(targetOutput3, output3);
}
开发者ID:nagaozen,项目名称:MsieJavaScriptEngine,代码行数:35,代码来源:InteropTestsBase.cs
示例7: ctor_DateTime_whenLocalTime
public void ctor_DateTime_whenLocalTime()
{
Date expected = "2012-03-26";
var actual = new Date(new DateTime(2012, 03, 25, 2, 1, 0, DateTimeKind.Local)).ToDateTime().AddDays(1).ToDate();
Assert.Equal(expected, actual);
}
开发者ID:KarlDirck,项目名称:cavity,代码行数:7,代码来源:Date.Facts.cs
示例8: CalculateFee
/// <summary>
/// If the book is returned on or before the expected return date, no fine will be charged, in other words fine is 0.
/// If the book is returned in the same month as the expected return date, Fine = 15 Hackos × Number of late days
/// If the book is not returned in the same month but in the same year as the expected return date, Fine = 500 Hackos × Number of late months
/// If the book is not returned in the same year, the fine is fixed at 10000 Hackos.
/// </summary>
static int CalculateFee(Date returnDate, Date expectedDate)
{
if (returnDate.year > expectedDate.year) { return 10000; }
else if ((returnDate.year == expectedDate.year) && returnDate.month > expectedDate.month) { return (returnDate.month - expectedDate.month) * 500; }
else if ((returnDate.year == expectedDate.year && returnDate.month == expectedDate.month) && returnDate.day > expectedDate.day) { return (returnDate.day - expectedDate.day) * 15; }
else { return 0; } // returned early
}
开发者ID:joshimoo,项目名称:Challenges,代码行数:13,代码来源:LibraryFine.cs
示例9: CanConstructFromDateTime
public void CanConstructFromDateTime()
{
Date d1 = new Date(new DateTime(2001, 2, 3, 4, 5, 6, 7).AddTicks(8));
Date d2 = new Date(2001, 2, 3);
Assert.AreEqual(d1, d2);
Assert.IsTrue(d1.Equals(d2));
}
开发者ID:NaveinKumar,项目名称:csharp-date,代码行数:7,代码来源:DateTests.cs
示例10: AddMinutes_2280_AreEqual
public void AddMinutes_2280_AreEqual()
{
var act = TestStruct.AddMinutes(2 * 24 * 60);
var exp = new Date(1970, 02, 16);
Assert.AreEqual(exp, act);
}
开发者ID:Corniel,项目名称:Qowaiv,代码行数:7,代码来源:DateTest.cs
示例11: AddMonths_12_AreEqual
public void AddMonths_12_AreEqual()
{
var act = TestStruct.AddMonths(12);
var exp = new Date(1971, 02, 14);
Assert.AreEqual(exp, act);
}
开发者ID:Corniel,项目名称:Qowaiv,代码行数:7,代码来源:DateTest.cs
示例12: AddMilliseconds_Arround3Days_AreEqual
public void AddMilliseconds_Arround3Days_AreEqual()
{
var act = TestStruct.AddMilliseconds(3 * 24 * 60 * 60 * 1003);
var exp = new Date(1970, 02, 17);
Assert.AreEqual(exp, act);
}
开发者ID:Corniel,项目名称:Qowaiv,代码行数:7,代码来源:DateTest.cs
示例13: AddHours_41_AreEqual
public void AddHours_41_AreEqual()
{
var act = TestStruct.AddHours(41);
var exp = new Date(1970, 02, 15);
Assert.AreEqual(exp, act);
}
开发者ID:Corniel,项目名称:Qowaiv,代码行数:7,代码来源:DateTest.cs
示例14: Equals_ConstructorDateWithTime_DoesNotCompareTime
public void Equals_ConstructorDateWithTime_DoesNotCompareTime()
{
var dayWithTime = new Date(new DateTime(2011, 1, 1, 1, 0, 0));
var sameDayWithOutTime = new Date(new DateTime(2011, 1, 1));
Expect(dayWithTime, Is.EqualTo(sameDayWithOutTime));
}
开发者ID:phoenixwebgroup,项目名称:DotNetExtensions,代码行数:7,代码来源:DateTests.cs
示例15: ViewMoverKenBurnsStyle
public ViewMoverKenBurnsStyle(CameraParameters from, CameraParameters to, double time, Date fromDateTime, Date toDateTime, InterpolationType type)
{
InterpolationType = type;
if (Math.Abs(from.Lng - to.Lng) > 180)
{
if (from.Lng > to.Lng)
{
from.Lng -= 360;
}
else
{
from.Lng += 360;
}
}
this.fromDateTime = fromDateTime;
this.toDateTime = toDateTime;
dateTimeSpan = toDateTime - fromDateTime;
this.from = from.Copy();
this.to = to.Copy();
fromTime = Date.Now;
toTargetTime = time;
}
开发者ID:spamarti,项目名称:wwt-web-client,代码行数:26,代码来源:IViewMover.cs
示例16: ToDateRemovesAllTimePortion
public void ToDateRemovesAllTimePortion()
{
Date d1 = new DateTime(2001, 2, 3, 4, 5, 6, 7).AddTicks(8).ToDate();
Date d2 = new Date(2001, 2, 3);
Assert.AreEqual(d1, d2);
Assert.IsTrue(d1.Equals(d2));
}
开发者ID:NaveinKumar,项目名称:csharp-date,代码行数:7,代码来源:DateTests.cs
示例17: ExportRaw
public string ExportRaw(ClientConfiguration clientConfiguration, Date from, Date to, string[] events = null)
{
try
{
var uri = MixPanelEndpointConfiguration.RawExportUrl;
var parameterDictionary = new Dictionary<string, string>();
parameterDictionary.Add(FromDateParamName, from.ToString());
parameterDictionary.Add(ToDateParamName, to.ToString());
if (events != null
&& events.Any())
parameterDictionary.Add(EventParamName, StringifyEvents(events));
var callingUri =
new Uri(uri.ToString() + "?" + string.Join("&", parameterDictionary.Select(x => x.Key + "=" + x.Value)));
var webClientResponse = _webClient.QueryUri(callingUri,
new BasicAuthentication { UserName = clientConfiguration.Secret });
return webClientResponse;
}
catch (WebException ex)
{
TryHandleWebException(ex);
throw new MixPanelClientException(ex);
}
catch (Exception ex)
{
throw new MixPanelClientException(ex);
}
}
开发者ID:raderick,项目名称:MixPanel.CsExport,代码行数:32,代码来源:MixPanelClient.cs
示例18: GetDailyPrintNumber
public static int GetDailyPrintNumber(Date date, int refNumber, Date refDate, SpecialDay noPrintDays, Dictionary<int, int> noPrintDates, Dictionary<int, int> noPrintNumbers)
{
int no = refNumber;
Date date2 = refDate;
while (date > date2)
{
date2 = date2.AddDays(1);
if (!noPrintDates.ContainsKey(date2.AbsoluteDay) && !SpecialDayTools.IsSpecialDay(noPrintDays, date2))
{
do
{
no++;
} while (noPrintNumbers.ContainsKey(no));
}
}
while (date < date2)
{
if (!noPrintDates.ContainsKey(date2.AbsoluteDay) && !SpecialDayTools.IsSpecialDay(noPrintDays, date2))
{
do
{
no--;
} while (noPrintNumbers.ContainsKey(no));
}
date2 = date2.AddDays(-1);
}
return no;
}
开发者ID:labeuze,项目名称:source,代码行数:28,代码来源:zprint.cs
示例19: MultipleTypeCustomInstanceAnnotationsOnErrorShouldRoundtrip
public void MultipleTypeCustomInstanceAnnotationsOnErrorShouldRoundtrip()
{
var originalInt = new KeyValuePair<string, ODataValue>("int.error", new ODataPrimitiveValue(1));
var originalDouble = new KeyValuePair<string, ODataValue>("double.error", new ODataPrimitiveValue(double.NaN));
DateTimeOffset dateTimeOffset = new DateTimeOffset(2012, 10, 10, 12, 12, 59, new TimeSpan());
var originalDateTimeOffset = new KeyValuePair<string, ODataValue>("DateTimeOffset.error", new ODataPrimitiveValue(dateTimeOffset));
Date date = new Date(2014, 12, 12);
var originalDate = new KeyValuePair<string, ODataValue>("Date.error", new ODataPrimitiveValue(date));
TimeOfDay time = new TimeOfDay(10, 12, 3, 9);
var originaltime = new KeyValuePair<string, ODataValue>("TimeOfDay.error", new ODataPrimitiveValue(time));
TimeSpan timeSpan = new TimeSpan(12345);
var originalTimeSpan = new KeyValuePair<string, ODataValue>("TimeSpan.error", new ODataPrimitiveValue(timeSpan));
GeographyPoint geographyPoint = GeographyPoint.Create(32.0, -100.0);
var originalGeography = new KeyValuePair<string, ODataValue>("Geography.error", new ODataPrimitiveValue(geographyPoint));
var originalNull = new KeyValuePair<string, ODataValue>("null.error", new ODataNullValue());
var complexValue = new ODataComplexValue
{
TypeName = "ns.ErrorDetails",
Properties = new[] { new ODataProperty { Name = "ErrorDetailName", Value = "inner property value" } }
};
var originalComplex = new KeyValuePair<string, ODataValue>("sample.error", complexValue);
var error = this.WriteThenReadErrorWithInstanceAnnotation(originalInt, originalDouble, originalDate, originalDateTimeOffset, originaltime, originalTimeSpan, originalGeography, originalNull, originalComplex);
var annotation = RunBasicVerificationAndGetAnnotationValue("int.error", error);
annotation.Should().BeOfType<ODataPrimitiveValue>();
annotation.As<ODataPrimitiveValue>().Value.Should().Be(1);
annotation = RunBasicVerificationAndGetAnnotationValue("double.error", error);
annotation.Should().BeOfType<ODataPrimitiveValue>();
annotation.As<ODataPrimitiveValue>().Value.Should().Be(double.NaN);
annotation = RunBasicVerificationAndGetAnnotationValue("Date.error", error);
annotation.Should().BeOfType<ODataPrimitiveValue>();
annotation.As<ODataPrimitiveValue>().Value.Should().Be(date);
annotation = RunBasicVerificationAndGetAnnotationValue("DateTimeOffset.error", error);
annotation.Should().BeOfType<ODataPrimitiveValue>();
annotation.As<ODataPrimitiveValue>().Value.Should().Be(dateTimeOffset);
annotation = RunBasicVerificationAndGetAnnotationValue("TimeOfDay.error", error);
annotation.Should().BeOfType<ODataPrimitiveValue>();
annotation.As<ODataPrimitiveValue>().Value.Should().Be(time);
annotation = RunBasicVerificationAndGetAnnotationValue("TimeSpan.error", error);
annotation.Should().BeOfType<ODataPrimitiveValue>();
annotation.As<ODataPrimitiveValue>().Value.Should().Be(timeSpan);
annotation = RunBasicVerificationAndGetAnnotationValue("Geography.error", error);
annotation.Should().BeOfType<ODataPrimitiveValue>();
annotation.As<ODataPrimitiveValue>().Value.Should().Be(geographyPoint);
annotation = RunBasicVerificationAndGetAnnotationValue("null.error", error);
annotation.Should().BeOfType<ODataNullValue>();
annotation = RunBasicVerificationAndGetAnnotationValue("sample.error", error);
annotation.Should().BeOfType<ODataComplexValue>();
annotation.As<ODataComplexValue>().Properties.First().Value.Should().Be("inner property value");
}
开发者ID:larsenjo,项目名称:odata.net,代码行数:60,代码来源:CustomInstanceAnnotationRoundtripJsonLightTests.cs
示例20: BlendState
public BlendState()
{
switchedTime = new Date(1990, 0, 0, 0, 0, 0, 0);
state = false;
targetState = state;
this.delayTime = 1000;
}
开发者ID:spamarti,项目名称:wwt-web-client,代码行数:7,代码来源:BlendState.cs
注:本文中的System.Date类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论