本文整理汇总了C#中System.JsDate类的典型用法代码示例。如果您正苦于以下问题:C# JsDate类的具体用法?C# JsDate怎么用?C# JsDate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JsDate类属于System命名空间,在下文中一共展示了JsDate类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: JsImplDateTime
static JsImplDateTime()
{
MinValue = new JsDate(0).As<JsImplDateTime>();
MinValue.setUTCFullYear(1, 0, 1);
MaxValue = new JsDate(0).As<JsImplDateTime>();
MaxValue.setUTCFullYear(9999, 11, 31);
}
示例2: YMDHConstructorWorks
public void YMDHConstructorWorks() {
var dt = new JsDate(2011, 7, 12, 13);
Assert.AreEqual(dt.GetFullYear(), 2011);
Assert.AreEqual(dt.GetMonth(), 7);
Assert.AreEqual(dt.GetDate(), 12);
Assert.AreEqual(dt.GetHours(), 13);
}
示例3: Filters
public void Filters()
{
describe("Filters",()=>
{
describe("Currency filter",()=>
{
it("should format numbers to money amounts",()=>
{
currencyFilter f = Angular.BuiltinFilters.currencyFilter;
expect(f.Filter(0)) .toBe("$0.00");
expect(f.Filter(5.75)) .toBe("$5.75");
expect(f.Filter(1000000)) .toBe("$1,000,000.00");
expect(f.Filter(-5.75)) .toBe("($5.75)");
expect(f.Filter(5.753)) .toBe("$5.75");
expect(f.Filter(5.75,"€")).toBe("€5.75");
});
});
describe("Date filter",()=>
{
dateFilter f = Angular.BuiltinFilters.dateFilter;
JsDate d = new JsDate(1972,4,3);
it("should format dates to U.S. format",()=>{ expect(f.Filter(d)).toBe("May 3, 1972"); });
it("should format short dates",()=>{ expect(f.Filter(d,"dd/MM/yy")).toBe("03/05/72"); });
it("should format long dates",()=>{ expect(f.Filter(d,"dd/MM/yyyy")).toBe("03/05/1972"); });
});
});
}
示例4: JsImplDateTime
public JsImplDateTime(int year, int month, int day)
{
this.date = new JsDate();
Year = year;
Month = month;
Day = day;
}
示例5: FormatDateWorks
public void FormatDateWorks()
{
var backupDec = Q.Culture.DateSeparator;
try
{
Q.Culture.DateSeparator = "/";
var date = new JsDate(2009, 0, 2, 3, 4, 5, 6); // 02.01.2009 03:04:05.006
Assert.AreEqual(Q.FormatDate(date, "dd/MM/yyyy"), "02/01/2009", "'/': dd/MM/yyy");
Assert.AreEqual(Q.FormatDate(date, "d/M/yy"), "2/1/09", "'/': d/M/yy");
Assert.AreEqual(Q.FormatDate(date, "d.M.yyyy"), "2.1.2009", "'/': d.M.yyy");
Assert.AreEqual(Q.FormatDate(date, "yyyyMMdd"), "20090102", "'/': yyyyMMdd");
Assert.AreEqual(Q.FormatDate(date, "hh:mm tt"), "03:04 AM", "'/': hh:mm tt");
Assert.AreEqual(Q.FormatDate(date, "yyyy-MM-ddTHH:mm:ss.fff"), "2009-01-02T03:04:05.006", "'/': yyyy-MM-ddTHH:mm:ss.fff");
Q.Culture.DateSeparator = ".";
Assert.AreEqual(Q.FormatDate(date, "dd/MM/yyyy"), "02.01.2009", "'.': dd/MM/yyy");
Assert.AreEqual(Q.FormatDate(date, "d/M/yy"), "2.1.09", "'.': d/M/yy");
Assert.AreEqual(Q.FormatDate(date, "d-M-yyyy"), "2-1-2009", "'.': d-M-yyy");
Assert.AreEqual(Q.FormatDate(date, "yyyy-MM-ddTHH:mm:ss.fff"), "2009-01-02T03:04:05.006", "'.': yyyy-MM-ddTHH:mm:ss.fff");
}
finally
{
Q.Culture.DecimalSeparator = backupDec;
}
}
示例6: YMDHNSConstructorWorks
public void YMDHNSConstructorWorks() {
var dt = new JsDate(2011, 7, 12, 13, 42, 56);
Assert.AreEqual(dt.GetFullYear(), 2011);
Assert.AreEqual(dt.GetMonth(), 7);
Assert.AreEqual(dt.GetDate(), 12);
Assert.AreEqual(dt.GetHours(), 13);
Assert.AreEqual(dt.GetMinutes(), 42);
Assert.AreEqual(dt.GetSeconds(), 56);
}
示例7: ConvertingMutableDateToDateReturnsANewButEqualInstance
public void ConvertingMutableDateToDateReturnsANewButEqualInstance()
{
var mdt = new JsDate(2011, 7, 12);
DateTime dt = (DateTime)mdt;
Assert.IsFalse((object)dt == (object)mdt);
Assert.AreEqual(mdt.GetFullYear(), 2011);
Assert.AreEqual(mdt.GetMonth(), 7);
Assert.AreEqual(mdt.GetDate(), 12);
}
示例8: dateToRFC3339String
public static string dateToRFC3339String(JsDate date)
{
if (date != null ) {
var jsonDate = date.toJSON();
return jsonDate.substring(0, 10);
}
return null;
}
示例9: TypePropertiesAreCorrect
public void TypePropertiesAreCorrect() {
Assert.AreEqual(typeof(JsDate).FullName, "ss.JsDate");
Assert.IsTrue(typeof(JsDate).IsClass);
Assert.IsTrue(typeof(IComparable<JsDate>).IsAssignableFrom(typeof(JsDate)));
Assert.IsTrue(typeof(IEquatable<JsDate>).IsAssignableFrom(typeof(JsDate)));
object o = new JsDate();
Assert.IsTrue(o is JsDate);
Assert.IsTrue(o is IComparable<JsDate>);
Assert.IsTrue(o is IEquatable<JsDate>);
var interfaces = typeof(JsDate).GetInterfaces();
Assert.AreEqual(interfaces.Length, 2);
Assert.IsTrue(interfaces.Contains(typeof(IComparable<JsDate>)));
Assert.IsTrue(interfaces.Contains(typeof(IEquatable<JsDate>)));
}
示例10: FormatDateWorks
public void FormatDateWorks()
{
var backupDec = Q.Culture.DateSeparator;
var backupDateFormat = Q.Culture.DateFormat;
var backupDateTimeFormat = Q.Culture.DateTimeFormat;
try
{
Q.Culture.DateSeparator = "/";
Q.Culture.DateFormat = "dd/MM/yyyy";
Q.Culture.DateTimeFormat = "dd/MM/yyyy HH:mm:ss";
var date = new JsDate(2029, 0, 2, 3, 4, 5, 6); // 02.01.2029 03:04:05.006
Assert.AreEqual(Q.FormatDate(date, "dd/MM/yyyy"), "02/01/2029", "'/': dd/MM/yyy");
Assert.AreEqual(Q.FormatDate(date, "d/M/yy"), "2/1/29", "'/': d/M/yy");
Assert.AreEqual(Q.FormatDate(date, "d.M.yyyy"), "2.1.2029", "'/': d.M.yyy");
Assert.AreEqual(Q.FormatDate(date, "yyyyMMdd"), "20290102", "'/': yyyyMMdd");
Assert.AreEqual(Q.FormatDate(date, "hh:mm tt"), "03:04 AM", "'/': hh:mm tt");
Assert.AreEqual(Q.FormatDate(date, "yyyy-MM-ddTHH:mm:ss.fff"), "2029-01-02T03:04:05.006", "'/': yyyy-MM-ddTHH:mm:ss.fff");
Assert.AreEqual(Q.FormatDate(date, "d"), "02/01/2029", "'/': d");
Assert.AreEqual(Q.FormatDate(date, "g"), "02/01/2029 03:04", "'/': g");
Assert.AreEqual(Q.FormatDate(date, "G"), "02/01/2029 03:04:05", "'/': G");
Assert.AreEqual(Q.FormatDate(date, "s"), "2029-01-02T03:04:05", "'/': s");
Assert.AreEqual(Q.FormatDate(date, "u"), Q.FormatISODateTimeUTC(date), "'/': u");
Q.Culture.DateSeparator = ".";
Assert.AreEqual(Q.FormatDate(date, "dd/MM/yyyy"), "02.01.2029", "'.': dd/MM/yyy");
Assert.AreEqual(Q.FormatDate(date, "d/M/yy"), "2.1.29", "'.': d/M/yy");
Assert.AreEqual(Q.FormatDate(date, "d-M-yyyy"), "2-1-2029", "'.': d-M-yyy");
Assert.AreEqual(Q.FormatDate(date, "yyyy-MM-ddTHH:mm:ss.fff"), "2029-01-02T03:04:05.006", "'.': yyyy-MM-ddTHH:mm:ss.fff");
Assert.AreEqual(Q.FormatDate(date, "g"), "02.01.2029 03:04", "'.': g");
Assert.AreEqual(Q.FormatDate(date, "G"), "02.01.2029 03:04:05", "'.': G");
Assert.AreEqual(Q.FormatDate(date, "s"), "2029-01-02T03:04:05", "'.': s");
Assert.AreEqual(Q.FormatDate(date, "u"), Q.FormatISODateTimeUTC(date), "'.': u");
}
finally
{
Q.Culture.DecimalSeparator = backupDec;
Q.Culture.DateFormat = backupDateFormat;
Q.Culture.DateTimeFormat = backupDateTimeFormat;
}
}
示例11: ToJSONWorks
public void ToJSONWorks()
{
Assert.AreEqual(Q.ToJSON(12345), "12345", "Number");
Assert.AreEqual(Q.ToJSON("abcd\"'e"), "\"abcd\\\"'e\"", "String");
var date = new JsDate(2013, 12, 27, 16, 19, 35, 345);
Assert.AreEqual(Q.ToJSON(date), "\"" + Q.Externals.FormatISODateTimeUTC(date) + "\"", "Date/Time");
Assert.AreEqual(Q.ToJSON(12345.6780), "12345.678", "Double");
object o = new { num = 5, str = "abc", date = date };
string json = Q.ToJSON(o);
Assert.IsTrue(Script.TypeOf(json) == "string", "Ensure serialized object is string");
var deserialized = jQuery.ParseJson(json);
o.As<dynamic>().date = Q.Externals.FormatISODateTimeUTC(date);
Assert.AreEqual(deserialized, o, "Compare original object and deserialization");
}
示例12: clone
public static object clone(object obj)
{
if ( ( obj == null) || ( [email protected]( obj ) != "object" ) ) {
return obj;
}
//Dates
if ( obj is JsDate ) {
var copy = new JsDate();
copy.setTime( obj.As<JsDate>().getTime() );
return copy;
}
//Array
if (obj is JsArray) {
var copy = new JsArray();
var current = obj.As<JsArray>();
for (var i = 0; i < current.length; i++ ) {
copy[ i ] = clone( current[ i ] );
}
return copy;
}
//Object
if (obj is JsObject) {
var copy = new JsObject();
var current = obj.As<JsObject>();
foreach (var key in current ) {
if ( current.hasOwnProperty( key )) {
copy[ key ] = clone( current[ key ] );
}
}
return copy;
}
return null;
}
示例13: MillisecondSinceEpochConstructorWorks
public void MillisecondSinceEpochConstructorWorks() {
var dt = new JsDate(1440L * 60 * 500 * 1000);
Assert.AreEqual(dt.GetFullYear(), 1971);
}
示例14: DefaultConstructorReturnsTodaysDate
public void DefaultConstructorReturnsTodaysDate() {
var dt = new JsDate();
Assert.IsTrue(dt.GetFullYear() > 2011);
}
示例15: GetUtcDayWorks
public void GetUtcDayWorks() {
var dt = new JsDate(JsDate.Utc(2011, 7, 12, 13, 42, 56, 345));
Assert.AreEqual(dt.GetUtcDay(), 5);
}