public void CurrentDateTest()
        {
            string validTestDate = DateTime.UtcNow.ToString("dd-MM-yyyy");
            string result        = CustomDateTime.CurrentDate();

            Assert.AreEqual(result, validTestDate);
        }
        /// <summary>
        /// Reads the prj file and check if an update has been made already
        /// </summary>
        /// <param name="pathToPrjFile"></param>
        private void ChangeMetadataFile(string pathToPrjFile)
        {
            try
            {
                var metadata = new Metadata
                {
                    ExchangedDate   = CustomDateTime.CustomExchangeDate(DateTime.Now),
                    ExchangedTime   = CustomDateTime.CustomExchangeTime(DateTime.Now),
                    LastChangedDate = CustomDateTime.CreateCustomDate(DateTime.Now)
                };

                using (var reader = new StreamReader(pathToPrjFile))
                {
                    string fileContent = reader.ReadToEnd();
                    reader.Close();

                    if (fileContent.Contains("PromptForNewWorkingDir"))
                    {
                        //that means we need to add "PromptForNewWorkingDir" line
                        MedatataBuilder(pathToPrjFile, metadata, false);
                    }
                    else
                    {
                        //the prj has been edited before so we don't need to add this line anymore, just update
                        MedatataBuilder(pathToPrjFile, metadata, true);
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Logger.Error($"ChangeMetadataFile method: {ex.Message}\n {ex.StackTrace}");
            }
        }
        public RollingOverWeekFileAppender()
        {
            CalcThisSunday(DateTime.Now);
            IDateTime dt = new CustomDateTime(thisSunday);

            DateTimeStrategy = dt;
        }
Beispiel #4
0
        public static void RegisterNetXPStandard(this IRegister uc)
        {
            //cnf
            uc.Register <IConfigFactory, ConfigFactory>();

            //cmpr
            uc.Register <ICompression, DeflateCompress>(DILifeTime.Singleton);

            #region Processes

            //Process
            uc.Register <NetStandard.Processes.IIOTerminal, IOTerminal>();

            #endregion

            //Reflect
            uc.Register <IReflector, Reflector>(DILifeTime.Singleton);

            //System Information
            //ISysInfo need to be implemented in their os system.
            uc.Register <NetStandard.SystemInformation.IStorageInfo, SystemInformation.Implementations.SysInfo>();
            var customDateTime = new CustomDateTime(0);
            uc.RegisterInstance <ICustomDateTime>(customDateTime);
            uc.Register <IServiceInformer, ServiceInformer>(DILifeTime.Singleton);

            //System Managers
            uc.Register <IServiceManager, ServiceManagerForWindows>(OSPlatformType.Windows.ToString(), DILifeTime.Singleton);
            uc.Register <IServiceManager, ServiceManagerForLinux>(OSPlatformType.Linux.ToString(), DILifeTime.Singleton);
            uc.Register <IServiceManager, ServiceManager>(DILifeTime.Singleton);
            uc.Register <IServiceManagerFactory, ServiceManagerFactory>(DILifeTime.Singleton);

            //Operative System
            uc.Register <IOperativeSystem, OperativeSystem>(DILifeTime.Singleton);
        }
 public void TestCustomTypeMapper()
 {
     var utcNow = DateTime.UtcNow;
     var customDateTime = new CustomDateTime { DateTime = utcNow };
     BsonValue bsonValue;
     Assert.AreEqual(true, BsonTypeMapper.TryMapToBsonValue(customDateTime, out bsonValue));
     Assert.AreEqual(utcNow, bsonValue.AsDateTime);
 }
Beispiel #6
0
 public NguoiDung(int maNguoiDung, string hoTen, Int32 ngaySinh, string email, string soDienThoai)
 {
     this.MaNguoiDung = maNguoiDung;
     this.HoTen       = hoTen;
     this.NgaySinh    = CustomDateTime.FromIntegerTime(ngaySinh);
     this.Email       = email;
     this.SoDienThoai = soDienThoai;
 }
Beispiel #7
0
 public static dynamic GetTSObject(CustomDateTime dynObject)
 {
     if (dynObject is null)
     {
         return(null);
     }
     return(dynObject.teklaObject);
 }
    public void TestCustomDateTime()
    {
        var expected = new CustomDateTime {
            Value = new DateTime(1776, 7, 4)
        };
        var actual = Roundtrip(expected);

        Assert.AreEqual(expected.Value, actual.Value);
    }
Beispiel #9
0
 public ThuNhap(int maThuNhap, int maThuChiThang, int maNhomThuNhap, UInt32 soTien, Int32 thoiGian, string moTa)
 {
     this.MaThuNhap     = maThuNhap;
     this.MaThuChiThang = maThuChiThang;
     this.MaNhomThuNhap = maNhomThuNhap;
     this.SoTien        = soTien;
     this.ThoiGian      = CustomDateTime.FromIntegerTime(thoiGian);
     this.MoTa          = moTa;
 }
Beispiel #10
0
 public ChiTieu(int maChiTieu, int maThuChiThang, int maNhomChiTieu, UInt32 soTien, Int32 thoiGian, string moTa)
 {
     this.MaChiTieu     = maChiTieu;
     this.MaThuChiThang = maThuChiThang;
     this.MaNhomChiTieu = maNhomChiTieu;
     this.SoTien        = soTien;
     this.ThoiGian      = CustomDateTime.FromIntegerTime(thoiGian);
     this.MoTa          = moTa;
 }
Beispiel #11
0
        public void TimeElapsedInYearsSince_InvalidGameDate_ReturnZero()
        {
            //ARRANGE
            CustomDateTime time = new CustomDateTime(5196, 7, 11);
            //ACT
            long days = time.TimeElapsedInYearsSince(new StandardDateTime(new System.DateTime(5196, 11, 1)));

            //ASSERT
            Assert.AreEqual(0, days);
        }
 static ServiceStackSerializer()
 {
     // use custom serialization only for our own types
     JsConfig <CustomDate> .SerializeFn            = c => c;
     JsConfig <CustomDate> .DeSerializeFn          = s => CustomDate.Parse(s);
     JsConfig <CustomDateTime> .SerializeFn        = c => c;
     JsConfig <CustomDateTime> .DeSerializeFn      = s => CustomDateTime.Parse(s);
     JsConfig <CustomDateTimeSpace> .SerializeFn   = c => c;
     JsConfig <CustomDateTimeSpace> .DeSerializeFn = s => CustomDateTimeSpace.Parse(s);
 }
Beispiel #13
0
        public void TestCustomTypeMapper()
        {
            var utcNow         = DateTime.UtcNow;
            var customDateTime = new CustomDateTime {
                DateTime = utcNow
            };
            BsonValue bsonValue;

            Assert.AreEqual(true, BsonTypeMapper.TryMapToBsonValue(customDateTime, out bsonValue));
            Assert.AreEqual(utcNow, bsonValue.AsDateTime);
        }
        public void DateTimeFuncsExceptionTest(int sYear, int sMonth, int sDay,
                                               int eYear, int eMonth, int eDay)
        {
            // Arrange
            DateTime startDate = new DateTime(sYear, sMonth, sDay);
            DateTime endDate   = new DateTime(eYear, eMonth, eDay);


            // Assert
            Assert.Throws <Exception>(() => { CustomDateTime.DatesDifference(startDate, endDate); });
        }
        public void AppointmentDateValidateTest()
        {
            string validTestDate    = "12 05 2021";
            string notValidTestDate = "12 05 2019";

            bool result = CustomDateTime.AppointmentDateValidate(validTestDate);

            Assert.IsTrue(result);

            result = CustomDateTime.AppointmentDateValidate(notValidTestDate);
            Assert.IsFalse(result);
        }
        public void CheckDateTimeFormatTest()
        {
            string validTestDate    = "2013 05 30";
            string notvalidTestDate = "1500 08 32";

            bool result = CustomDateTime.CheckDateTimeFormat(validTestDate);

            Assert.IsTrue(result);

            result = CustomDateTime.CheckDateTimeFormat(notvalidTestDate);
            Assert.IsFalse(result);
        }
Beispiel #17
0
    public CustomDateTime(double jday)
    {
        CustomDateTime temp = FromJulianDay(jday);

        year   = temp.year;
        month  = temp.month;
        day    = temp.day;
        hour   = temp.hour;
        minute = temp.minute;
        second = temp.second;
        era    = temp.era;
    }
        public void TestCustomTypeMapper()
        {
            var utcNow          = DateTime.UtcNow;
            var utcNowTruncated = utcNow.AddTicks(-(utcNow.Ticks % 10000));
            var customDateTime  = new CustomDateTime {
                DateTime = utcNow
            };
            BsonValue bsonValue;

            Assert.AreEqual(true, BsonTypeMapper.TryMapToBsonValue(customDateTime, out bsonValue));
            Assert.AreEqual(utcNowTruncated, bsonValue.ToUniversalTime());
        }
        public void GetAppointmentEndTimeTest()
        {
            var validInicio = "14:00"; var validDuracao = 90;
            var expectedValid = "15:30";
            var resultValid   = CustomDateTime.GetAppointmentEndTime(validInicio, validDuracao);

            Assert.AreEqual(resultValid, expectedValid);

            var expectedNotValid = "14:30";
            var resultNotValid   = CustomDateTime.GetAppointmentEndTime(validInicio, validDuracao);

            Assert.AreNotEqual(resultNotValid, expectedNotValid);
        }
Beispiel #20
0
    void OnGotStatus(Status result)
    {
        status = result;
        CustomDateTime stellariumDateTime = new CustomDateTime(result.time.jday);

        hourInput.text      = stellariumDateTime.hour.ToString("D2");
        minuteInput.text    = stellariumDateTime.minute.ToString("D2");
        secondInput.text    = stellariumDateTime.second.ToString("D2");
        monthDropdown.value = stellariumDateTime.month - 1;
        dayInput.text       = stellariumDateTime.day.ToString();
        yearInput.text      = (stellariumDateTime.year * (stellariumDateTime.year < 0?-1:1)).ToString();
        SetTimeSlider();
    }
Beispiel #21
0
        //private Boolean IsFirstDateCanBeScheduled(DateTime CurrentDay)
        //{
        //    Boolean Rtn = false;


        //    EnumDayOfWeeks DayOfTheWeek = CustomDateTime.CustomDayOfTheWeek(CurrentDay.DayOfWeek);
        //    int AmountOfDayFound = (from a in SetOfDaysOfWeekCourseCanBeScheulded
        //                            where a == DayOfTheWeek//a.HasFlag(DayOfTheWeek)
        //                            select a).ToList<EnumDayOfWeeks>().Count();
        //    if (AmountOfDayFound > 0)
        //    {
        //        Rtn = true;
        //    }

        //    return Rtn;

        //}

        private void SetAvailableCoursePeriodForFacilitators()
        {
            foreach (FacilitatorPeriod FAP in FacilitatorAvailablePeriods)
            {
                DateTime INITIAL_DATE = FAP.StartDate;

                //Get First Dat That Scheduling Can Start
                DateTime FIRST_DAY_CAN_BE_SCHEDULED_FROM_SET = FAP.StartDate;
                while (FIRST_DAY_CAN_BE_SCHEDULED_FROM_SET.Date < FAP.EndDate.Date)
                {
                    Boolean IsFirstDayFound = false;
                    while (!IsFirstDayFound)
                    {
                        EnumDayOfWeeks DayOfTheWeek = CustomDateTime.CustomDayOfTheWeek(FIRST_DAY_CAN_BE_SCHEDULED_FROM_SET.DayOfWeek);
                        if ((from a in SetOfDaysOfWeekCourseCanBeScheulded
                             where a == DayOfTheWeek//a.HasFlag(DayOfTheWeek)
                             select a).ToList <EnumDayOfWeeks>().Count() > 0)
                        {
                            IsFirstDayFound = true;
                        }
                        else
                        {
                            FIRST_DAY_CAN_BE_SCHEDULED_FROM_SET = FIRST_DAY_CAN_BE_SCHEDULED_FROM_SET.AddDays(1);
                        }
                    }


                    //DateTime must be inclusive of the initial date so 1 day must be subtracted from the returned possible end date.
                    DateTime EndDateForCurrentPossibleSchedule = CustomDateTime.getCustomDateTime(FIRST_DAY_CAN_BE_SCHEDULED_FROM_SET.Date.AddDays(-1), CourseDuration, SetOfDaysOfWeekCourseCanBeScheulded);
                    if (EndDateForCurrentPossibleSchedule.Date <= FAP.EndDate.Date)
                    {
                        //Add Schedule Option To List
                        ListOfAvailableCoursePeriodByFacilitator.Add(new AvailableCoursePeriodByFacilitatorResultSet()
                        {
                            CourseID        = this.CourseID,
                            CourseName      = this.CourseName,
                            FacilitatorID   = FAP.FacillitatorID,
                            FacilitatorName = FAP.FacilitatorName,
                            CourseStartDate = FIRST_DAY_CAN_BE_SCHEDULED_FROM_SET.Date,
                            CourseEndDate   = EndDateForCurrentPossibleSchedule.Date
                        });
                        FIRST_DAY_CAN_BE_SCHEDULED_FROM_SET = EndDateForCurrentPossibleSchedule.Date.AddDays(1);
                    }
                    else
                    {
                        FIRST_DAY_CAN_BE_SCHEDULED_FROM_SET = FAP.EndDate.Date;
                    }
                }
            }
        }
Beispiel #22
0
        public void TimeElapsedInDaysSince_ValidGameDate_ReturnCorrectNumberOfDays()
        {
            //ARRANGE
            CustomDateTime time = new CustomDateTime(5196, 7, 11);

            time.SetNumberOfDaysPerMonth(20);
            time.SetNumberOfMonthsInYear(18);
            //ACT
            long days = time.TimeElapsedInDaysSince(new CustomDateTime(5196, 11, 1, 1, 2));

            //ASSERT
            Assert.AreEqual(360, time.GetNumberOfDaysInYear());
            Assert.AreEqual(70, days);
        }
Beispiel #23
0
 public void UpdateDateTime()
 {
     StellariumServer.Instance.MainService.SetTime(CustomDateTime.ToJulianDay(new CustomDateTime(
                                                                                  StringToInt(yearInput.text),
                                                                                  monthDropdown.value + 1,
                                                                                  StringToInt(dayInput.text),
                                                                                  StringToInt(hourInput.text),
                                                                                  StringToInt(minuteInput.text),
                                                                                  StringToInt(secondInput.text),
                                                                                  (CustomDateTime.Era)(StringToInt(yearInput.text) < 0?0:1)
                                                                                  )),
                                                   0f
                                                   );
 }
        public void MinutesDurationFormatTest()
        {
            var valid         = 90;
            var resultValid   = CustomDateTime.MinutesDurationFormat(valid);
            var expectedValid = "01:30";

            Assert.AreEqual(resultValid, expectedValid);

            var notValid         = 200;
            var resultNotValid   = CustomDateTime.MinutesDurationFormat(notValid);
            var expectedNotValid = "03:30";

            Assert.AreNotEqual(resultNotValid, expectedNotValid);
        }
Beispiel #25
0
 public CongViec(int maCongViec, int maNhomCongViec, int maNguoiDung, string tieuDe, string noiDung,
                 string diaDiem, Int32 batDau, Int32 ketThuc, string ghiChu, bool trangThai)
 {
     this.MaCongViec     = maCongViec;
     this.MaNhomCongViec = maNhomCongViec;
     this.MaNguoiDung    = maNguoiDung;
     this.TieuDe         = tieuDe;
     this.NoiDung        = noiDung;
     this.DiaDiem        = diaDiem;
     this.BatDau         = CustomDateTime.FromIntegerTime(batDau);
     this.KetThuc        = CustomDateTime.FromIntegerTime(ketThuc);
     this.GhiChu         = ghiChu;
     this.TrangThai      = trangThai;
 }
Beispiel #26
0
 private bool LessThan30Days(DateTime startDate, DateTime endDate)
 {
     try
     {
         if (CustomDateTime.DatesDifference(startDate, endDate) <= 30 && CustomDateTime.DatesDifference(startDate, endDate) >= 1)
         {
             return(true);
         }
         return(false);
     }
     catch (Exception)
     {
         throw;
     }
 }
Beispiel #27
0
        public void Age_PersonWithDOB_ValidAgeReturned()
        {
            //ARRANGE
            Person         person      = new Person("That Dude", Guid.NewGuid());
            CustomDateTime dateOfBirth = new CustomDateTime(3876, 10, 10);

            person.DateOfBirth = dateOfBirth;

            CustomDateTime currentGameTime = new CustomDateTime(3917, 7, 30);
            //ACT
            int age = person.Age(currentGameTime);

            //ASSERT
            Assert.AreEqual(40, age);
        }
        public void DateTimeFuncsDays(int sYear, int sMonth, int sDay,
                                      int eYear, int eMonth, int eDay,
                                      int days)
        {
            // Arrange
            DateTime startDate = new DateTime(sYear, sMonth, sDay);
            DateTime endDate   = new DateTime(eYear, eMonth, eDay);


            // Act
            var result = CustomDateTime.DatesDifference(startDate, endDate);

            // Assert
            Assert.AreEqual(result, days);
        }
Beispiel #29
0
        /// <summary>
        /// Reads the prj file and check if an update has been made already
        /// </summary>
        private void ChangeMetadataFile(string pathToPrjFile)
        {
            var metadata = new Metadata
            {
                ExchangedDate   = CustomDateTime.CustomExchangeDate(DateTime.Now),
                ExchangedTime   = CustomDateTime.CustomExchangeTime(DateTime.Now),
                LastChangedDate = CustomDateTime.CreateCustomDate(DateTime.Now)
            };

            using (var reader = new StreamReader(pathToPrjFile))
            {
                var fileContent = reader.ReadToEnd();
                reader.Close();

                MetadataBuilder(pathToPrjFile, metadata, !fileContent.Contains("PromptForNewWorkingDir"));
            }
        }
        private Boolean IsFirstDateCanBeScheduled(DateTime CurrentDay, List <CurriculumCourseDayCanBeScheduled> CurriculumCourseDayCanBeScheduledList)
        {
            Boolean Rtn = false;


            EnumDayOfWeeks DayOfTheWeek     = CustomDateTime.CustomDayOfTheWeek(CurrentDay.DayOfWeek);
            int            AmountOfDayFound = (from a in CurriculumCourseDayCanBeScheduledList
                                               where a.DayOfWeekID == (int)DayOfTheWeek
                                               select a).ToList <CurriculumCourseDayCanBeScheduled>().Count();

            if (AmountOfDayFound > 0)
            {
                Rtn = true;
            }

            return(Rtn);
        }
        public void FormatDateTest()
        {
            var validTestDate = "12 07 2021";
            var resultValid   = CustomDateTime.FormatDate(validTestDate);
            var expectedValid = "12-07-2021";

            Assert.AreEqual(resultValid, expectedValid);


            var  notValidTestDate = "12sas07sx2021";
            var  resultNotValid   = "";
            bool threwException   = false;

            try{ resultNotValid = CustomDateTime.FormatDate(notValidTestDate); }
            catch { threwException = true; }

            Assert.IsTrue(threwException);
        }
 public void TestCustomTypeMapper()
 {
     var utcNow = DateTime.UtcNow;
     var utcNowTruncated = utcNow.AddTicks(-(utcNow.Ticks % 10000));
     var customDateTime = new CustomDateTime { DateTime = utcNow };
     BsonValue bsonValue;
     Assert.Equal(true, BsonTypeMapper.TryMapToBsonValue(customDateTime, out bsonValue));
     Assert.Equal(utcNowTruncated, bsonValue.ToUniversalTime());
 }