Represents the ECMA Date object.
        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));
        }
Example #2
0
 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;
 }
Example #3
0
 public Construction(BuildingType type, Settlement location, Date today)
 {
     _type = type;
     _location = location;
     _startDate = today;
     //_resourceRequirements = _type.RequirementsFor(location);
 }
Example #4
0
        /// <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;
        }
 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);
 }
		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);
		}
Example #7
0
        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);
        }
Example #8
0
 /// <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
 }
Example #9
0
 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));
 }
Example #10
0
        public void AddMinutes_2280_AreEqual()
        {
            var act = TestStruct.AddMinutes(2 * 24 * 60);
            var exp = new Date(1970, 02, 16);

            Assert.AreEqual(exp, act);
        }
Example #11
0
        public void AddMonths_12_AreEqual()
        {
            var act = TestStruct.AddMonths(12);
            var exp = new Date(1971, 02, 14);

            Assert.AreEqual(exp, act);
        }
Example #12
0
        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);
        }
Example #13
0
        public void AddHours_41_AreEqual()
        {
            var act = TestStruct.AddHours(41);
            var exp = new Date(1970, 02, 15);

            Assert.AreEqual(exp, act);
        }
        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));
        }
Example #15
0
        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;
        }
Example #16
0
 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));
 }
		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);
			}
		}
Example #18
0
 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;
 }
        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");
        }
Example #20
0
 public BlendState()
 {
     switchedTime = new Date(1990, 0, 0, 0, 0, 0, 0);
     state = false;
     targetState = state;
     this.delayTime = 1000;
 }
Example #21
0
        public static void Main() {
            Foo f = new Foo(0, 1);
            Bar b = new Bar(0, 1, new Foo(0, 1));
            Test t = new Test();
            Date d = new Date("3/9/1976");
            int[] items = new Array();
            int[] items2 = new int[] { 1, 2 };
            int[] items3 = { 4, 5 };
            int[] items4 = new int[5];
            ArrayList list = new ArrayList();
            ArrayList list2 = new ArrayList(5);
            ArrayList list3 = new ArrayList("abc", "def", "ghi");
            ArrayList list4 = new ArrayList(1, 2, 3);
            Date[] dates = new Date[] {
                             new Date("1/1/2006"),
                             new Date("1/1/2005") };

            Point p = new Point(0, 0);

            CustomDictionary cd = new CustomDictionary();
            CustomDictionary cd2 = new CustomDictionary("abc", 123, "def", true);

            object o1 = Script.CreateInstance(typeof(Test));

            Type type1 = typeof(Foo);
            object o2 = Script.CreateInstance(type1, 1, 2);
            object o3 = Script.CreateInstance(typeof(Bar), 1, 2, (Foo)o2);

            Function f1 = new Function("alert('hello');");
            Function f2 = new Function("alert(s);", "s");
            Function f3 = new Function("alert(greeting + ' ' + name + '!');", "greeting", "name");
        }
Example #22
0
                public Date AddDays(int days)
                {
                    var date = new Date();
                    if (Day + days > MaxDaysOfTheMonth)
                    {
                        date.Day = Day + days - MaxDaysOfTheMonth;
                        if (Month == 12)
                        {
                            date.Month = 1;
                            date.Year = Year + 1;
                        }
                        else
                        {
                            date.Month = Month + 1;
                            date.Year = Year;
                        }
                    }
                    else
                    {
                        date.Day = Day + days;
                        date.Month = Month;
                        date.Year = Year;
                    }

                    return date;
                }
Example #23
0
 // GetLeMondePrintNumber
 public static int GetPrintNumber(Date date)
 {
     // Le monde - 2012-12-02 - no 21110.pdf
     // Le monde - 2012-10-12 - no 21066.pdf
     // Le monde - 2012-07-19 - no 20993.pdf
     // pas de journal le 1er mai sauf si c'est un dimanche, journal le dimanche 1er mai 2011
     // Test_GetLeMondePrintNumber("2012-04-29"); // ok  20925
     // Test_GetLeMondePrintNumber("2012-05-02"); // ok  20926
     Date dateRef = new Date(2012, 12, 2);
     int noRef = 21110;
     while (date > dateRef)
     {
         if (dateRef.DayOfWeek != DayOfWeek.Sunday && (dateRef.Month != 5 || dateRef.Day != 1 || dateRef.DayOfWeek == DayOfWeek.Sunday))
             noRef++;
         dateRef = dateRef.AddDays(1);
     }
     while (date < dateRef)
     {
         if (dateRef.DayOfWeek != DayOfWeek.Monday && (dateRef.Month != 5 || dateRef.Day != 1 || dateRef.DayOfWeek == DayOfWeek.Sunday))
             noRef--;
         dateRef = dateRef.AddDays(-1);
     }
     if (date != dateRef) throw new PBException("error date not found {0}", date.ToString());
     return noRef;
 }
Example #24
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Cronofy.EventTime"/>
        /// class.
        /// </summary>
        /// <param name="date">
        /// The <see cref="Date"/> the instance relates to.
        /// </param>
        /// <param name="timeZoneId">
        /// The time zone identifier of the instance, must not be empty.
        /// </param>
        /// <exception cref="ArgumentException">
        /// Thrown if <paramref name="timeZoneId"/> is empty.
        /// </exception>
        public EventTime(Date date, string timeZoneId)
        {
            Preconditions.NotEmpty("timeZoneId", timeZoneId);

            this.date = date;
            this.timeZoneId = timeZoneId;
            this.hasTime = false;
        }
 public TimeRegistration(Guid id, Client client, Project project, Task task,
                         string description, Date date, Time from, Time to)
 {
     ApplyChange(new TimeRegistrationCreated(id, client.Id, project.Id, 
                                             task.Name, task.Rate,
                                             description, date, from, to, 
                                             DateTime.UtcNow));
 }
Example #26
0
 public void getMonthNameAllCases()
 {
     for (int i = 1; i < 13; i++)
     {
         Date date = new Date(2, i, 2010);
         Console.WriteLine("Mjesec je {0}", date.getMonthName());
     }
 }
Example #27
0
 internal Character(World world, string firstName, string lastName, Sex gender, Date birthDate)
     : base(world)
 {
     FirstName = firstName;
     LastName = lastName;
     BirthDate = birthDate;
     Gender = gender;
 }
 private void godate_Click(object sender, EventArgs e)
 {
     MessageBox.Show(this.end.Text);
     Date datepage = new Date();
     datepage.sDate.Text = this.start.Text;
     datepage.eDate.Text = this.end.Text;
     this.Close();
     datepage.Show();
 }
Example #29
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Cronofy.EventTime"/> class.
        /// </summary>
        /// <param name="dateTimeOffset">
        /// The time the instance relates to.
        /// </param>
        /// <param name="timeZoneId">
        /// The time zone identifier of the instance, must not be empty.
        /// </param>
        /// <exception cref="ArgumentException">
        /// Thrown if <paramref name="timeZoneId"/> is empty.
        /// </exception>
        public EventTime(DateTimeOffset dateTimeOffset, string timeZoneId)
        {
            Preconditions.NotEmpty("timeZoneId", timeZoneId);

            this.dateTimeOffset = dateTimeOffset;
            this.date = Date.From(dateTimeOffset);
            this.timeZoneId = timeZoneId;
            this.hasTime = true;
        }
Example #30
0
 public void addMonthTest()
 {
     int year = 2013; // TODO: 初始化为适当的值
     int month = 3; // TODO: 初始化为适当的值
     int day = 3;  // TODO: 初始化为适当的值
     int expected = 1;
     Date target = new Date(year, month, day); // TODO: 初始化为适当的值
     expected =target.addMonth(5);
 }