Exemple #1
0
        public static bool GetRoleHours(SimDescription sim, ref DateAndTime start, ref DateAndTime end)
        {
            if ((sim != null) && (sim.AssignedRole != null))
            {
                IRoleGiverExtended roleGivingObject = sim.AssignedRole.RoleGivingObject as IRoleGiverExtended;
                if (roleGivingObject != null)
                {
                    float startTime;
                    float endTime;
                    roleGivingObject.GetRoleTimes(out startTime, out endTime);

                    start = new DateAndTime(SimClock.ConvertToTicks((float)SimClock.DayToInt(SimClock.CurrentDayOfWeek), TimeUnit.Days));
                    end = new DateAndTime(SimClock.ConvertToTicks((float)SimClock.DayToInt(SimClock.CurrentDayOfWeek), TimeUnit.Days));
                    if (SimClock.HoursPassedOfDay >= endTime)
                    {
                        start= SimClock.Add(start, TimeUnit.Hours, startTime);
                        end = SimClock.Add(end, TimeUnit.Hours, endTime + 24f);
                    }
                    else
                    {
                        start = SimClock.Add(start, TimeUnit.Hours, startTime);
                        end = SimClock.Add(end, TimeUnit.Hours, endTime);
                    }

                    return true;
                }
            }

            return false;
        }
        static void Main()
        {
            var dt = new DateAndTime {StartDate = new Date(2008, 7, 22), StartTime = new Time(12, 30, 50)};
            dt.Save();
            Console.WriteLine("DateAndTime saved with id = {0}", dt.Id);

            var n = DateAndTime.FindById(dt.Id);
            // looks like a .net bug: in Console.WriteLine, n.StartDate are different with n.StartDate.ToString()...
            Console.WriteLine("DateAndTime read as StartDate = {0}, StartTime = {1}", n.StartDate.ToString(), n.StartTime.ToString());

            n.Delete();
        }
Exemple #3
0
        //trips with default input values (5 ft surf height and 500 max price)
        public List <Trip> GetTripsDefault()
        {
            List <Trip> trips = new List <Trip>();

            try
            {
                using (SqlConnection conn = new SqlConnection(connectionString))
                {
                    conn.Open();

                    SqlCommand cmd = new SqlCommand(SQL_GetTripsDefault, conn);

                    cmd.Parameters.AddWithValue("@inputMinSurfHeight", 500);
                    cmd.Parameters.AddWithValue("@inputMaxPrice", 5);
                    SqlDataReader reader = cmd.ExecuteReader();



                    while (reader.Read())
                    {
                        Trip t = new Trip();
                        t.InputDepartureDate = DateAndTime.GetPastDate();
                        t.InputMaxPrice      = 500;
                        t.InputMinSurfHeight = 5;
                        t.InputReturnDate    = DateAndTime.GetFutureDate();
                        t.DepartureDate      = Convert.ToDateTime(reader["departure_date"]).Date;
                        t.Latitude           = Convert.ToString(reader["latitude"]);
                        t.LocationName       = Convert.ToString(reader["name"]);
                        t.Longitude          = Convert.ToString(reader["longitude"]);
                        t.MaxSurfHeight      = Convert.ToDecimal(reader["max_height"]);
                        t.NumberOfSurfDays   = Convert.ToInt32(reader["num_of_days_with_surf"]);
                        t.Price                  = Convert.ToDecimal(reader["min_flight_price"]);
                        t.ReturnDate             = Convert.ToDateTime(reader["return_date"]).Date;
                        t.SpotName               = Convert.ToString(reader["spot_name"]);
                        t.SpotId                 = Convert.ToInt32(reader["spot_id"]);
                        t.FlightId               = Convert.ToInt32(reader["flight_id"]);
                        t.OriginAirportCode      = Convert.ToString(reader["origin_airport_code"]);
                        t.DestinationAirportCode = Convert.ToString(reader["airport_code"]);

                        trips.Add(t);
                    }
                }
            }
            catch (SqlException)
            {
                throw;
            }

            return(trips);
        }
Exemple #4
0
        private void Btnsave_Click(object sender, EventArgs e)
        {
            var      datTim1 = Convert.ToDateTime("#1/1/" + stryear + "#");
            DateTime datTim2 = this.dtptime.Value;

            int wD = Convert.ToInt32(DateAndTime.DateDiff(DateInterval.Day, datTim1, datTim2, FirstDayOfWeek.Sunday, FirstWeekOfYear.Jan1));

            i[wD] = this.txtmemo.Text;
            if (i[wD].Length > 0)
            {
                MessageBox.Show("일기가 정상적으로 저장되었습니다.", "알림", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.txtmemo.Clear();
            }
        }
Exemple #5
0
        /// <summary>
        /// Unlocks delay if the current date is greater than continued date
        /// </summary>
        /// <param name="currDate">The current date</param>
        public void Unlock(DateAndTime currDate)
        {
            if (DateDelayed != null && DateContinued != null)
            {
                DateCompare compare = TimeAndDateUtility.ComputeDiff(DateDelayed, currDate, DateContinued).Comparison;
                Lock = compare != DateCompare.None;

                if (!Lock)
                {
                    DateDelayed   = null;
                    DateContinued = null;
                }
            }
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     UserValidate();
     ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "anything", "test();", true);
     ChkNonContract_CheckedChanged(null, null);
     Buss.Init(this, UserInfo);
     if (!IsPostBack)
     {
         Buss.LoadForm();
         ViewState["RowID"] = 0;
         Fdate.Text         = DateAndTime.GetDate10Digit();
         Ldate.Text         = DateAndTime.GetDate10Digit();
     }
 }
Exemple #7
0
        private void FrmAttendance_Load(object sender, EventArgs e)
        {
            DateAndTime.Start();
            String a = @"C:\video.mp4";

            axWindowsMediaPlayer1.URL = a;
            axWindowsMediaPlayer1.settings.setMode("loop", true);
            GlobalVar.time = "Time In";
            clear();
            this.ActiveControl = textBox1;
            PresentTeacher();
            PresentStudent();
            Retrieve();
        }
        public void ReadUserDateAndTimeTest_DoesNotReturnCorrectString()
        {
            // Arrange
            string      date = "09/23/2012";
            string      time = "Problem";
            string      expectedDateAndTime = "2012_09_23 08";
            DateAndTime dt = new DateAndTime();

            // Act
            string dateAndTimeResult = dt.ReadUserDateAndTime(date, time);

            // Assert
            Assert.AreNotEqual(expectedDateAndTime, dateAndTimeResult, "Expected [date: 23_09_2012; time: 08:18:08] to be false");
        }
Exemple #9
0
        public static int GetCurrentSeasonDay()
        {
            if (!SeasonsManager.Enabled)
            {
                return(0);
            }

            DateAndTime currentTime = SimClock.Subtract(SimClock.CurrentTime(), TimeUnit.Hours, SimClock.CurrentTime().Hour);

            // Number of remaining days
            int num = ((int)SimClock.ElapsedTime(TimeUnit.Days, currentTime, SeasonsManager.ExpectedEndTime));

            return((int)SeasonsManager.GetSeasonLength(SeasonsManager.CurrentSeason) - num);
        }
Exemple #10
0
        public static string GetRoleHours(SimDescription sim)
        {
            DateAndTime start = DateAndTime.Invalid;
            DateAndTime end   = DateAndTime.Invalid;

            if (Roles.GetRoleHours(sim, ref start, ref end))
            {
                return(Common.LocalizeEAString(false, "Gameplay/MapTags/MapTag:ProprietorHours", new object[] { start.ToString(), end.ToString() }));
            }
            else
            {
                return(null);
            }
        }
        public void ReadUserDateAndTimeTest()
        {
            // Arrange
            string      date = "09/23/2012";
            string      time = "08";
            string      expectedDateAndTime = "2012_09_23 08";
            DateAndTime dt = new DateAndTime();

            // Act
            string dateAndTimeResult = dt.ReadUserDateAndTime(date, time);

            // Assert
            Assert.AreEqual(expectedDateAndTime, dateAndTimeResult, "Expected [date: 09/23/2012; time: 08] to be 2012_09_23 08");
        }
        public static int StrToBLTime(string timeStr)
        {
            try {
                if (timeStr == null)
                {
                    return(0);
                }

                var time = DateAndTime.TimeValue(timeStr);
                return((DateAndTime.Hour(time) * 100) + DateAndTime.Minute(time));
            } catch (Exception) {
                return(0);
            }
        }
Exemple #13
0
        public DateTime GetVersionDate()
        {
            string directoryPath = Class33.Class31_0.Info.DirectoryPath;
            string assemblyName  = Class33.Class31_0.Info.AssemblyName;

            byte[] rawAssembly = File.ReadAllBytes(directoryPath + "/" + assemblyName + ".dll");
            string text        = Assembly.Load(rawAssembly).GetName().Version.ToString();

            text = text.Split(new char[]
            {
                '.'
            })[2];
            return(DateAndTime.DateAdd("d", (double)Conversions.ToLong(text), new DateTime(630822816000000000L)));
        }
Exemple #14
0
 void clear()
 {
     lbllastname.Text = "";
     lbllrn.Text      = "";
     lbltrack.Text    = "";
     lblgrade.Text    = "";
     lblsection.Text  = "";
     lblstatus.Text   = "";
     lblcurdate.Text  = "";
     lbladviser.Text  = "";
     lblsemester.Text = "";
     lblstrand.Text   = "";
     DateAndTime.Start();
 }
Exemple #15
0
        public static long KeyAge(string sKey, HttpApplicationState ha)
        {
            string sAge = ReadKey(sKey, ha);

            if (string.IsNullOrEmpty(sAge))
            {
                UpdateKey(sKey, Strings.Trim(DateTime.Now.ToString()), ha);
                sAge = ReadKey(sKey, ha);
            }
            long dDiff = 0;

            dDiff = Math.Abs(DateAndTime.DateDiff(DateInterval.Minute, DateTime.Now, Convert.ToDateTime(sAge)));
            return(dDiff);
        }
Exemple #16
0
        public static void RemoveDeadAuction(int AuctionNum)
        {
            string Dates = "";

            //This is probably broken:
            Dates = String.Format(DateTime.Today.ToString(), "m/d/yyyy");

            if (DateAndTime.DateDiff("d", DateTime.Parse(Auction[AuctionNum].Date), DateTime.Parse(Dates), FirstDayOfWeek.System, FirstWeekOfYear.System) >= Auction[AuctionNum].EndDate)
            {
                // Give the auction to the previous bidder, they won ;p
                AuctionTimedOut(AuctionNum);
                DestroyAuction(AuctionNum);
            }
        }
Exemple #17
0
        /// <summary>
        ///  根据日期获取年龄.
        ///  Author :   XP-PC/Shaipe
        ///  Created:  09-30-2014
        /// </summary>
        /// <param name="targetDate">The target date.</param>
        /// <returns>System.Int64.</returns>
        public static long GetYears(DateTime targetDate)
        {
            long BirthDay = DateAndTime.DateDiff(DateInterval.Year, targetDate, DateTime.Now, FirstDayOfWeek.Sunday, FirstWeekOfYear.Jan1);

            if (int.Parse(BirthDay.ToString()) < 0)
            {
                //new ECFException("经鉴定,你是未来人");
            }
            else
            {
                return(BirthDay);
            }
            return(0);
        }
Exemple #18
0
 public void ClearForm()
 {
     _host.ReceiptDate = DateAndTime.GetDate10Digit();
     _host.txtSearechPostReceiptSerial.Text             =
         _host.txtSearechPostReceiptSeri.Text           =
             _host.txtSaderKonandehCheque.Text          =
                 _host.txtReceiptSerialNo.Text          =
                     _host.txtAccountNoCheque.Text      =
                         _host.txtPayerName.Text        =
                             _host.txtComment.Text      =
                                 _host.txtPrice.Text    =
                                     _host.txtSeri.Text =
                                         string.Empty;
 }
Exemple #19
0
        private void TrackBar_tossing_Scroll(object sender, EventArgs e)
        {
            string XDate      = "";
            int    SelectData = 0;

            SelectData = TrackBar_tossing.Value;
            for (var i = 0; i <= SelectData - 1; i++)
            {
                XDate = System.Convert.ToString(DateAndTime.DateAdd("d", System.Convert.ToDouble(-i), DateTime.Now.Date).ToString("yyyyMMdd"));
                PVar.StorXData[(int)i]   = System.Convert.ToString(DateAndTime.DateAdd("d", System.Convert.ToDouble(-i), DateTime.Now.Date).ToString("MM/dd"));
                PVar.StorTossing[(int)i] = double.Parse(FileRw.IniGetStringValue(PVar.UIChartYieldOverViewName, XDate, "Tossing", "0"));                  //当天抛料率
            }
            FileRw.Chart_Curve(Chart_Tossing, "Tossing(Unit:%)", "", "", "Tossing", PVar.StorXData, PVar.StorTossing, 0, 0, 0, false);
        }
        /// <summary>
        /// Gets all the items for the mothly glance list view
        /// </summary>
        /// <param name="groups">The groups to categorize events</param>
        /// <returns>The list of ListViewItem to display</returns>
        public ListViewItem[] GetAll(ListViewGroupCollection groups)
        {
            DateTime today     = DateTime.Now;
            int      maxDay    = DateTime.DaysInMonth(today.Year, today.Month);
            DateTime startDate = today.AddDays(-(today.Day - 1));
            DateTime endDate   = today.AddDays(maxDay - today.Day).AddHours(23 - today.Hour).AddMinutes(59 - today.Minute).AddSeconds(59 - today.Second);

            DateAndTime todaysDate = TimeAndDateUtility.ConvertDateTime_DateAndTime(today);
            DateAndTime start      = TimeAndDateUtility.ConvertDateTime_DateAndTime(startDate);
            DateAndTime end        = TimeAndDateUtility.ConvertDateTime_DateAndTime(endDate);

            List <SavedEvent>   events = _eventController.GetEvents(start, end).ToList();
            List <ListViewItem> items  = new List <ListViewItem>();

            events.ForEach(x =>
            {
                string[] details = CalculateStatus(todaysDate, x, end);
                string date      = details[1];

                ListViewItem item = new ListViewItem(details)
                {
                    Group =
                        date.Contains(COMPLETED) ? groups["Complete"]
                                : (date.Contains(STARTS_IN) ? groups["Upcoming"]
                                    : (date.Contains(ENDS_IN) ? groups["HappeningNow"]
                                        : (date.Contains(OVERDUE_FROM) ? groups["Overdue"] : null)))
                };

                item.Tag        = x.Id;
                bool groupIsSet = item.Group != null && !string.IsNullOrEmpty(item.Group.Name);
                if (groupIsSet)
                {
                    string groupName = item.Group.Name;

                    int groupIndex =
                        groupName == "Complete" ? 1
                                : groupName == "Upcoming" ? 2
                                    : groupName == "HappeningNow" ? 3
                                        : groupName == "Overdue" ? 4 : -1;

                    SetVisualDetails(groupIndex, item);
                    item.Tag = x.Id;
                }

                items.Add(item);
            }
                           );

            return(items.ToArray());
        }
        private void esAndPTAction(RddOutputBean rdd)
        {
            if (DateAndTime.DateDiff("d", tempDate, rdd.oldRdd) > 7)
            {
                tempReason += $"WARNING: RDD more than 7 days in advance.{Constants.vbCr}";
            }

            if (DateAndTime.Weekday(rdd.oldRdd, FirstDayOfWeek.Monday) > 5 && !rdd.isRddChangeAllowed)
            {
                tempReason  += $"WARNING: RDD on weekends are not allowed.{Constants.vbCr}";
                tempDelBlock = IDAConsts.DelBlocks.leadTimeBlock;
                tempDate     = rdd.oldRdd;
            }
        }
        public ActionResult FromDate(int?id, DateAndTime model)
        {
            var fromDate = model.GetDateTime();

            if (fromDate < DateTime.UtcNow.ToUkTimeFromUtc().AddMinutes(15))
            {
                ModelState.AddModelError("Hour", "Start time must be at least 15 minutes from now");
                ModelState.AddModelError("Minute", string.Empty);
            }

            if (DatesOverlapExistingSlip(MPID, fromDate))
            {
                ModelState.AddModelError("Date", "You have already submitted a slip for this date");
            }

            if (ModelState.IsValid)
            {
                if (id.HasValue)
                {
                    // Update an existing record
                    SlippingRequest slippingRequest = Get(id.Value);

                    if (slippingRequest != null && !IsSubmitted(slippingRequest))
                    {
                        slippingRequest.FromDate = model.GetDateTime();
                        CreateOrUpdate(slippingRequest);
                        return(RedirectToAction("ToDate", new { id }));
                    }
                    else
                    {
                        return(RedirectToAction("NotFound", "Home"));
                    }
                }
                else
                {
                    // Create a new record
                    SlippingRequest slippingRequest = new SlippingRequest()
                    {
                        FromDate = model.GetDateTime()
                    };
                    int requestId = CreateOrUpdate(slippingRequest);
                    return(RedirectToAction("ToDate", new { id = requestId }));
                }
            }
            else
            {
                return(View(model));
            }
        }
Exemple #23
0
        public override bool Run()
        {
            try
            {
                StandardEntry();
                if (!Target.StartComputing(this, SurfaceHeight.Table, true))
                {
                    StandardExit();
                    return(false);
                }
                DateAndTime firstDate = SimClock.CurrentTime();
                Target.StartVideo(Computer.VideoType.WordProcessor);

                StartStages();
                BeginCommodityUpdates();

                bool succeeded = false;

                try
                {
                    AnimateSim("WorkTyping");
                    succeeded = DoLoop(~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached));
                }
                finally
                {
                    EndCommodityUpdates(succeeded);
                }

                LawEnforcement job = OmniCareer.Career <LawEnforcement>(Actor.Occupation);

                float minutes = SimClock.ElapsedTime(TimeUnit.Minutes, firstDate, SimClock.CurrentTime());
                job.UpdateTimeSpentOnForensicAnalysis(minutes);
                Target.StopComputing(this, Computer.StopComputingAction.TurnOff, false);
                if (job.IsForensicAnalysisComplete(Computer.RunForensicAnalysis.kTotalTimeToFinishAnalysis))
                {
                    job.ResetForensicAnalysisStatistics();
                    Actor.ModifyFunds(Computer.RunForensicAnalysis.kRewardOnFinishingAnalysis);
                    Actor.ShowTNSIfSelectable(LocalizeString(Actor.SimDescription, "AnalysisComplete", new object[] { Actor, Computer.RunForensicAnalysis.kRewardOnFinishingAnalysis }), StyledNotification.NotificationStyle.kGameMessagePositive, ObjectGuid.InvalidObjectGuid, Actor.ObjectId);
                }

                StandardExit();
                return(true);
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);
                return(false);
            }
        }
        public virtual ActionResult Index(ForgottenPasswordModel model)
        {
            if (!ModelState.IsValid)
            {
                return(PartialView(MVC.ForgottenPassword.Views._Index, model));
            }

            bool isEmailExist = _userService.ExistsByEmail(model.Email);

            if (isEmailExist)
            {
                User   selecteduser     = _userService.GetUserByEmail(model.Email);
                string key              = Guid.NewGuid().ToString();
                var    newRequestTicket = new ForgottenPassword
                {
                    User          = selecteduser,
                    Key           = key,
                    ResetDateTime = DateAndTime.GetDateTime()
                };

                _forgttenPasswordService.Add(newRequestTicket);

                if (_emailService.SendResetPasswordConfirmationEmail(selecteduser.UserName, model.Email, key)
                    == SendingMailResult.Successful)
                {
                    _uow.SaveChanges();
                }
                else
                {
                    return(Json(new
                    {
                        result = "true",
                        message = "متاسفانه خطایی در ارسال ایمیل رخ داده است."
                    }));
                }

                return(Json(new
                {
                    result = "true",
                    message = "ایمیلی برای تایید بازنشانی کلمه عبور برای شما ارسال شد.اعتبارایمیل ارسالی 24 ساعت است."
                }));
            }

            return(Json(new
            {
                result = "false",
                message = "این ایمیل در سیستم ثبت نشده است"
            }));
        }
Exemple #25
0
        public virtual ActionResult AddSlider(AddSliderModel SliderModel)
        {
            var lstSliderStatus = new List <SelectListItem>
            {
                new SelectListItem {
                    Text = "عادی", Value = "visible", Selected = true
                },
                new SelectListItem {
                    Text = "پنهان", Value = "hidden"
                },
                new SelectListItem {
                    Text = "پیش نویس", Value = "draft"
                },
                new SelectListItem {
                    Text = "آرشیو", Value = "archive"
                }
            };

            ViewBag.SliderStatus = lstSliderStatus;

            if (!ModelState.IsValid)
            {
                return(PartialView(MVC.Admin.Shared.Views._ValidationSummery));
            }


            var Slider = new Slider
            {
                Priority     = SliderModel.SliderPriority,
                CreatedDate  = DateAndTime.GetDateTime(),
                Link         = SliderModel.SliderLink,
                Picture      = SliderModel.SliderPicture,
                Status       = SliderModel.SliderStatus.ToString().ToLower(),
                Title        = SliderModel.SliderTitle,
                EditedByUser = _userService.GetUserByUserName(User.Identity.Name)
            };


            Slider.User = _userService.GetUserByUserName(User.Identity.Name);

            _SliderService.AddSlider(Slider);
            _uow.SaveChanges();


            return(PartialView(MVC.Admin.Shared.Views._Alert,
                               new Alert {
                Message = "اسلاید جدید با موقیت در سیستم ثبت شد", Mode = AlertMode.Success
            }));
        }
        private void Close_Button_Click(object sender, EventArgs e)
        {
            DialogResult dialog = MessageBox.Show("Are you sure you want to exit?", "Closing App",
                                                  MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (dialog == DialogResult.Yes)
            {
                DateAndTime.Stop();
                Environment.Exit(1);
            }
            //else if(dialog == DialogResult.No)
            //{

            //}
        }
Exemple #27
0
        public static object MonthName(object month, object abbreviate)
        {
#if !NETSTANDARD
            return(DateAndTime.MonthName(Convert.ToInt32(month), Convert.ToBoolean(abbreviate)));
#else
            if (Convert.ToBoolean(abbreviate))
            {
                return(DateTimeFormatInfo.GetInstance(null).GetAbbreviatedMonthName(Convert.ToInt32(month)));
            }
            else
            {
                return(DateTimeFormatInfo.GetInstance(null).GetMonthName(Convert.ToInt32(month)));
            }
#endif
        }
Exemple #28
0
        private static bool CanAddInspection(string SectionID)
        {
            DateTime  dateTime  = DateAndTime.DateAdd(DateInterval.Day, (double)checked (-1 * Inspection.IInspectionWindow), DateAndTime.Today);
            DataTable dataTable = mdUtility.DB.GetDataTable("SELECT [INSP_DATA_ID] FROM Inspection_Data WHERE [insp_data_sec_id]={" + SectionID + "} AND ([INSP_DATA_INSP_DATE]>=#" + Conversions.ToString(dateTime) + "# AND [INSP_Source] <> 'InstallDate') AND (BRED_Status <> 'D' OR BRED_Status IS NULL)");

            if (dataTable.Rows.Count == 0)
            {
                return(true);
            }
            if ((uint)Microsoft.VisualBasic.CompilerServices.Operators.CompareString(mdUtility.fMainForm.CurrentLocation.ToString(), "", false) <= 0U)
            {
                return(false);
            }
            return(Microsoft.VisualBasic.CompilerServices.Operators.ConditionalCompareObjectEqual(mdUtility.DB.GetDataTable("SELECT Count(SAMP_DATA_ID) FROM Sample_Data WHERE [SAMP_DATA_INSP_DATA_ID]={" + dataTable.Rows[0]["INSP_DATA_ID"].ToString() + "} AND SAMP_DATA_LOC={" + Strings.Replace(mdUtility.fMainForm.tvInspection.GetNodeByKey(mdUtility.fMainForm.CurrentLocation).Tag.ToString(), "'", "''", 1, -1, CompareMethod.Binary) + "}").Rows[0][0], (object)0, false));
        }
        public static long GetDifferenceDaysBetweenTwoDates(string dateFirst, string dateSecond)
        {
            DateTime dateTimeFirst        = ParseStringToDate(dateFirst);
            DateTime dateTimeSecond       = ParseStringToDate(dateSecond);
            TimeSpan day                  = (dateTimeFirst - dateTimeSecond);
            TimeSpan day1                 = dateTimeFirst.Subtract(dateTimeSecond);
            double   daysBetweenTwoDates  = (dateTimeFirst - dateTimeSecond).Days;
            double   daysBetweenTwoDates1 = (dateTimeFirst - dateTimeSecond).TotalDays;
            double   daysBetweenTwoDates2 = dateTimeFirst.Subtract(dateTimeSecond).Days;
            double   daysBetweenTwoDates3 = dateTimeFirst.Subtract(dateTimeSecond).Days;
            long     days                 = DateAndTime.DateDiff(DateInterval.Day, dateTimeFirst, dateTimeSecond);

            //return daysBetweenTwoDates;
            return(days);
        }
Exemple #30
0
        public static int DateDiffInMonths(DateTime start_date, DateTime end_date)
        {
            long _monthsDiff = 0;

            _monthsDiff = DateAndTime.DateDiff(Microsoft.VisualBasic.DateInterval.Month,
                                               start_date, end_date, FirstDayOfWeek.System, FirstWeekOfYear.System);
            if (_monthsDiff > int.MaxValue)
            {
                throw new ApplicationException("Cannot process date diff more then " + int.MaxValue + " months");
            }
            else
            {
                return((int)_monthsDiff);
            }
        }
Exemple #31
0
        private IEnumerable <SavedEvent> GetDateRestrictedResults(DateAndTime start, DateAndTime end)
        {
            bool nullStart = start == null;
            bool nullEnd   = end == null;

            new List <SavedEvent>();
            DateAndTime min = TimeAndDateUtility.ConvertDateTime_DateAndTime(DateTime.MinValue);

            IEnumerable <SavedEvent> events = !nullEnd && !nullStart?
                                              _eventRepo.GetEvents(start, end).ToList() : (nullEnd && !nullStart ?
                                                                                           _eventRepo.GetEvents(start).ToList() : (nullStart && !nullEnd ?
                                                                                                                                   _eventRepo.GetEvents(min, end).ToList() : new List <SavedEvent>()));

            return(events);
        }
Exemple #32
0
 private void Start()
 {
     DateAndTime.TimeZone    = TimeZone;
     _FromDate.DateTimeStyle = DateAndTime;
     _FromDate     = DateAndTime.GetDatePAC();
     _FromDate.Day = 1;
     FromDate.CopyTo(_ShowOfDate);
     Saturday.Text  = DateAndTime.GetDayOfWeekName(0);
     Sunday.Text    = DateAndTime.GetDayOfWeekName(1);
     Monday.Text    = DateAndTime.GetDayOfWeekName(2);
     Tuesday.Text   = DateAndTime.GetDayOfWeekName(3);
     Wednesday.Text = DateAndTime.GetDayOfWeekName(4);
     Thursday.Text  = DateAndTime.GetDayOfWeekName(5);
     Friday.Text    = DateAndTime.GetDayOfWeekName(6);
 }
Exemple #33
0
 public int GetSpeed(DateAndTime time, int overrideSpeed)
 {
     return GetSpeed(time.DayOfWeek, (int)time.Hour, overrideSpeed);
 }
Exemple #34
0
        private IMiniSimDescription FindDeadPartner(IMiniSimDescription miniSim, bool mustBeSpouse)
        {
            if (miniSim.CASGenealogy.ISpouse != null)
            {
                if (mustBeSpouse)
                {
                    if (miniSim.CASGenealogy.PartnerType != PartnerType.Marriage)
                    {
                        return null;
                    }
                }

                return miniSim.CASGenealogy.ISpouse.IMiniSimDescription;
            }

            SimDescription sim = miniSim as SimDescription;
            if (sim == null)
            {
                return null;
            }

            Relationship choice = null;
            DateAndTime latest = new DateAndTime();

            bool endNow = false;

            foreach (Relationship relation in Relationship.Get(sim))
            {
                SimDescription other = relation.GetOtherSimDescription(sim);
                if (other == null) continue;

                switch (relation.CurrentLTR)
                {
                    case LongTermRelationshipTypes.Partner:
                    case LongTermRelationshipTypes.Spouse:
                    case LongTermRelationshipTypes.Fiancee:
                        if (!miniSim.IsDead)
                        {
                            // Live partners take precedence
                            if (!other.IsDead)
                            {
                                choice = relation;
                                endNow = true;
                                break;
                            }
                        }
                        break;
                }

                if (endNow)
                {
                    break;
                }

                switch (relation.CurrentLTR)
                {
                    case LongTermRelationshipTypes.Ex:
                    case LongTermRelationshipTypes.Partner:
                    case LongTermRelationshipTypes.ExSpouse:
                    case LongTermRelationshipTypes.Spouse:
                    case LongTermRelationshipTypes.Fiancee:
                        if ((!miniSim.IsDead) && (!other.IsDead)) continue;

                        if ((choice == null) || (latest < relation.LTR.WhenStateStarted))
                        {
                            choice = relation;
                            latest = relation.LTR.WhenStateStarted;

                        }
                        break;
                }
            }

            if (choice == null)
            {
                return null;
            }
            else
            {
                if (mustBeSpouse)
                {
                    if (endNow)
                    {
                        return null;
                    }

                    switch (choice.CurrentLTR)
                    {
                        case LongTermRelationshipTypes.Spouse:
                        case LongTermRelationshipTypes.ExSpouse:
                            break;
                        default:
                            return null;
                    }
                }

                return choice.GetOtherSimDescription(sim);
            }
        }
Exemple #35
0
 public FuneralSituation(Lot lot, SimDescription deadSim, Sim host, List<SimDescription> guests, OutfitCategories clothingStyle, DateAndTime startTime) 
     : base(lot, host, guests, clothingStyle, startTime)
 {
     mWhoDied = deadSim;
 }