private Duration SubtractIgnoringTimeStandard(JulianDate value, TimeStandard standard) { int days = Day - value.Day; double seconds = SecondsOfDay - value.SecondsOfDay; return(new Duration(days, seconds)); }
public Duration Subtract(JulianDate subtrahend) { const TimeStandard subtractionTimeStandard = TimeStandard.InternationalAtomicTime; if (subtractionTimeStandard != Standard && subtractionTimeStandard != subtrahend.Standard) { // Convert both the subtrahend and the minuend to the subtraction time standard. return(ToInternationalAtomicTime().SubtractIgnoringTimeStandard(subtrahend.ToInternationalAtomicTime())); } if (subtractionTimeStandard != Standard) { // Convert the minuend to the subtraction time standard - subtrahend is already in the correct standard. return(ToInternationalAtomicTime().SubtractIgnoringTimeStandard(subtrahend)); } if (subtractionTimeStandard != subtrahend.Standard) { // Convert the subtrahend to the subtraction time standard - minuend is already in the correct standard. return(SubtractIgnoringTimeStandard(subtrahend.ToInternationalAtomicTime())); } // Time standards match up, so do the subtraction directly. return(SubtractIgnoringTimeStandard(subtrahend)); }
/// <summary> /// Initializes a <see cref="JulianDate"/> from a <see cref="GregorianDate"/> where the <see cref="GregorianDate"/> /// is expressed in the given <see cref="TimeStandard"/>. If the date is during a leap second, the /// <see cref="JulianDate"/> will be expressed in <see cref="TimeStandard.InternationalAtomicTime"/> (TAI). /// </summary> /// <param name="gregorianDate">The <see cref="GregorianDate"/>.</param> /// <param name="standard"> /// The time standard in which the <paramref name="gregorianDate"/> is expressed. /// </param> public JulianDate(GregorianDate gregorianDate, TimeStandard standard) { JulianDate converted = gregorianDate.ToJulianDate(standard); m_day = converted.m_day; m_secondsOfDay = converted.m_secondsOfDay; m_timeStandard = converted.Standard; }
/// <summary> /// Returns a <see cref="TimeInterval"/> equivalent to this one where the time standard /// of the start and end dates has been converted to the specified standard. /// </summary> /// <param name="timeStandard">The time standard of the new interval.</param> /// <returns>An equivalent interval with the new time standard.</returns> public TimeInterval ToTimeStandard(TimeStandard timeStandard) { if (m_start.Standard == timeStandard && m_stop.Standard == timeStandard) { return(this); } return(new TimeInterval(m_start.ToTimeStandard(timeStandard), m_stop.ToTimeStandard(timeStandard))); }
public JulianDate ToTimeStandard(TimeStandard timeStandard) { JulianDate result; if (!TryConvertTimeStandard(timeStandard, out result)) { throw new ArgumentOutOfRangeException(CesiumLocalization.CannotRepresentLeapSecondAsUTCJulianDate); } return(result); }
public TimeInterval ToTimeStandard(TimeStandard timeStandard) { if (ReferenceEquals(m_start.Standard, timeStandard) && ReferenceEquals(m_stop.Standard, timeStandard)) { return(this); } return(new TimeInterval(m_start.ToTimeStandard(timeStandard), m_stop.ToTimeStandard(timeStandard))); }
public bool TryConvertTimeStandard(TimeStandard timeStandard, out JulianDate result) { if (timeStandard == Standard) { result = this; return(true); } if (timeStandard == TimeStandard.InternationalAtomicTime && Standard == TimeStandard.CoordinatedUniversalTime) { result = new JulianDate(Day, SecondsOfDay + LeapSeconds.Instance.GetTaiMinusUtc(this), timeStandard); return(true); } if (timeStandard == TimeStandard.CoordinatedUniversalTime && Standard == TimeStandard.InternationalAtomicTime) { return(LeapSeconds.Instance.TryConvertTaiToUtc(this, out result)); } result = MinValue; return(false); }
/// <summary> /// Initializes a <see cref="JulianDate"/> from the provided values. The values will be /// normalized so that the <see cref="SecondsOfDay"/> property is less than the length of the day. /// </summary> /// <param name="day">The whole number part of the date.</param> /// <param name="secondsOfDay">The time of day, expressed as seconds past noon on the given whole-number day.</param> /// <param name="timeStandard">The time standard to use for this Julian Date.</param> public JulianDate(int day, double secondsOfDay, TimeStandard timeStandard) { m_timeStandard = timeStandard; m_day = day; m_secondsOfDay = secondsOfDay; // Normalize so that the number of seconds is >= 0 and < a day. if (m_secondsOfDay < 0) { int wholeDays = (int)(m_secondsOfDay / TimeConstants.SecondsPerDay); --wholeDays; m_day += wholeDays; m_secondsOfDay -= TimeConstants.SecondsPerDay * wholeDays; if (m_secondsOfDay > TimeConstants.NextBefore86400) { // In theory m_secondsOfDay can't actually be greater than 86400.0. // But it can be equal to that, or it can be in the 80-bit floating point // unit and thus in between 86400.0 and the next smaller representable 64-bit // double. If it's the latter, it's in danger of being rounded to 86400.0. // 86400.0 is of course not a valid value for m_secondsOfDay, so we need to // reset it to 0.0 and increment m_day. // // This can happen if the original m_secondsOfDay coming in is a very small // negative number. When we add 86400.0 to it, we get 86400.0 instead of // something slightly less than that as expected, because a double has more // precision near 0.0 than near 86400.0. ++m_day; m_secondsOfDay = 0.0; } } else if (m_secondsOfDay >= TimeConstants.SecondsPerDay) { int wholeDays = (int)(m_secondsOfDay / TimeConstants.SecondsPerDay); m_day += wholeDays; m_secondsOfDay -= TimeConstants.SecondsPerDay * wholeDays; } }
public JulianDate Add(Duration duration) { const TimeStandard additionTimeStandard = TimeStandard.InternationalAtomicTime; if (additionTimeStandard != Standard) { // Do the addition in the addition time standard JulianDate resultInAdditionStandard = ToInternationalAtomicTime().AddIgnoringTimeStandard(duration); //then convert back if possible JulianDate result; if (resultInAdditionStandard.TryConvertTimeStandard(Standard, out result)) { return(result); } //if we couldn't convert back, then use the valid result in the addition standard return(resultInAdditionStandard); } // Time standards match up, so do the addition directly. return(AddIgnoringTimeStandard(duration)); }
public GregorianDate ToGregorianDate(TimeStandard standard) { return(new GregorianDate(this, standard)); }
public DateTime ToDateTime(TimeStandard standard) { return(ToGregorianDate(standard).ToDateTime()); }
/// <summary> /// Initializes a <see cref="JulianDate"/> from a <see cref="DateTime"/> and specified time standard. /// </summary> /// <param name="dateTime">The <see cref="DateTime"/>.</param> /// <param name="standard"> /// The time standard to use for this Julian Date. The <paramref name="dateTime"/> is assumed to be expressed /// in this time standard. /// </param> public JulianDate(DateTime dateTime, TimeStandard standard) : this(new GregorianDate(dateTime), standard) { }
/// <summary> /// Initializes a <see cref="JulianDate"/> from a double expressing the complete astronomical Julian Date. /// </summary> /// <param name="dayCount">The complete Julian date.</param> /// <param name="timeStandard">The time standard to use for this Julian Date.</param> public JulianDate(double dayCount, TimeStandard timeStandard) { m_timeStandard = timeStandard; m_day = (int)dayCount; m_secondsOfDay = (dayCount - m_day) * TimeConstants.SecondsPerDay; }
protected void Page_Load(object sender, EventArgs e) { btnAddToFav.Src = "http://" + HttpContext.Current.Request.Url.Host + "/Images/star.png"; var churchId = 0; Sample(); if (Request["id"] == null && Page.RouteData.Values["church-id"] == null && Page.RouteData.Values["church-id"] == null) { return; } if (Request["id"] != null) { churchId = Convert.ToInt32(Request["id"]); } else if (Page.RouteData.Values["church-id"] != null) { churchId = Convert.ToInt32(Page.RouteData.Values["church-id"]); } var service = new ChurchService(); var favoriteService = new FavoritesService(); var timeStandard = new TimeStandard(); churches = service.Find(churchId); Master.MetaTitle = $"{churches.MetaTitle}"; Master.MetaDescription = $"{churches.MetaDescription}"; maskData.Value = churches.MaskData; simbahanID.Value = churchId.ToString(); churchName.InnerHtml = churches.Parish; churchAddress.InnerHtml = churches.CompleteAddress; churchLastUpdate.InnerHtml = churches.LastUpdate.ToString("MMM d, yyyy"); churchHistory.InnerHtml = HttpUtility.HtmlDecode(churches.ChurchHistory) == "" ? "<h3>No Data Available.</h3>" : "<strong>" + churches.Parish + "</strong> " + HttpUtility.HtmlDecode(churches.ChurchHistory); churchType.InnerHtml = ChurchType.parseInt(churches.ChurchTypeID); churchEstablished.InnerHtml = churches.DateEstablished; churchFeastDay.InnerHtml = churches.FeastDay; churchPriest.InnerHtml = churches.Priest; churchVicariate.InnerHtml = churches.Vicariate; churchDiocese.InnerHtml = churches.Diocese; churchContact.InnerHtml = churches.ContactNo; churchWeb.HRef = "http://www." + churches.Website; churchWebsite.InnerHtml = churches.Website; adorationSchedule.InnerHtml = churches.AdorationDisplayText; churchMapAddress.InnerHtml = churches.CompleteAddress; churchMapDestination.Value = churches.CompleteAddress; baptismSchedule.InnerHtml = churches.BaptismDetails; weddingSchedule.InnerHtml = churches.WeddingDetails; officeHours.InnerHtml = churches.OfficeHours; devotionSchedule.InnerHtml = churches.DevotionSchedule; latitude.Value = churches.Latitude.ToString(); longitude.Value = churches.Longitude.ToString(); editChurchHistory.InnerHtml = churches.ChurchHistory; if (Auth.Check()) { if (favoriteService.IsChurchAlreadyInFavorites(Auth.user().Id, churches.SimbahanID)) { AddFav.Attributes.Add("style", "display: none;"); RemoveFav.Attributes.Add("style", "display: block;"); } else { AddFav.Attributes.Add("style", "display: block;"); RemoveFav.Attributes.Add("style", "display: none;"); } } else { RemoveFav.Attributes.Add("style", "display: none"); } List <MassDetailsModel> schedules; switch (DateTime.UtcNow.DayOfWeek) { case DayOfWeek.Sunday: schedules = churches.SundayMassSchedule; break; case DayOfWeek.Monday: schedules = churches.MondayMassSchedule; break; case DayOfWeek.Tuesday: schedules = churches.TuesdayMassSchedule; break; case DayOfWeek.Wednesday: schedules = churches.WednesdayMassSchedule; break; case DayOfWeek.Thursday: schedules = churches.ThursdayMassSchedule; break; case DayOfWeek.Friday: schedules = churches.FridayMassSchedule; break; case DayOfWeek.Saturday: schedules = churches.SaturdayMassSchedule; break; default: schedules = new List <MassDetailsModel>(); break; } var languages = new List <string>(); var massSchedules = new List <string>(); foreach (var mass in schedules) { if (mass.Language != "" && !languages.Contains(mass.Language)) { languages.Add(mass.Language); } massSchedules.Add(mass.Time); } var massDate = "No Mass Schedule for " + DateTime.UtcNow.DayOfWeek; churchMassLanguages.Attributes.Add("style", "display: none;"); if (massSchedules.Count > 0) { massDate = DateTime.UtcNow.DayOfWeek + " - " + string.Join(", ", massSchedules); churchMassLanguages.Attributes.Add("style", "display: block;"); } churchMassDates.InnerHtml = massDate; churchMassLanguages.InnerHtml = string.Join(", ", languages); adorationChapelSchedule.InnerHtml = churches.AdorationDisplayText; confessionSchedule.InnerHtml = churches.ConfessionDetails.Count > 0 ? churches.ConfessionDetails[0].Text : ""; if (!string.IsNullOrEmpty(churches.LocationType)) { var locationLabel = new CheckLabel(churches.LocationType); churchLocation.InnerHtml = locationLabel.ToHtml(); } foreach (var ventilation in churches.Ventilations) { var ventilationLabel = new CheckLabel(ventilation.VentType); churchVentilations.InnerHtml += ventilationLabel.ToHtml(); } foreach (var ventilation in churches.AdorationVentilations) { var ventilationLabel = new CheckLabel(ventilation); adorationVentilations.InnerHtml += ventilationLabel.ToHtml(); } foreach (var parking in churches.ChurchParking) { var parkingLabel = new CheckLabel(parking.ParkingType); churchParking.InnerHtml += parkingLabel.ToHtml(); } for (var i = 5; i <= 22; i++) { var row = new HtmlTableRow(); var dayTime = new HtmlTableCell(); var sundayMass = new HtmlTableCell(); var mondayMass = new HtmlTableCell(); var tuesdayMass = new HtmlTableCell(); var wednesdayMass = new HtmlTableCell(); var thursdayMass = new HtmlTableCell(); var fridayMass = new HtmlTableCell(); var saturdayMass = new HtmlTableCell(); var sundayTime = churches.SundayMassSchedule.FirstOrDefault(schedule => schedule.TimeStandardId == i); var mondayTime = churches.MondayMassSchedule.FirstOrDefault(schedule => schedule.TimeStandardId == i); var tuesdayTime = churches.TuesdayMassSchedule.FirstOrDefault(schedule => schedule.TimeStandardId == i); var wednesdayTime = churches.WednesdayMassSchedule.FirstOrDefault(schedule => schedule.TimeStandardId == i); var thursdayTime = churches.ThursdayMassSchedule.FirstOrDefault(schedule => schedule.TimeStandardId == i); var fridayTime = churches.FridayMassSchedule.FirstOrDefault(schedule => schedule.TimeStandardId == i); var saturdayTime = churches.SaturdayMassSchedule.FirstOrDefault(schedule => schedule.TimeStandardId == i); dayTime.InnerHtml = timeStandard.Time[i - 1]; sundayMass.InnerHtml = sundayTime != null ? sundayTime.Time + "<br/>" + sundayTime.Language : ""; mondayMass.InnerHtml = mondayTime != null ? mondayTime.Time + "<br/>" + mondayTime.Language : ""; tuesdayMass.InnerHtml = tuesdayTime != null ? tuesdayTime.Time + "<br/>" + tuesdayTime.Language : ""; wednesdayMass.InnerHtml = wednesdayTime != null ? wednesdayTime.Time + "<br/>" + wednesdayTime.Language : ""; thursdayMass.InnerHtml = thursdayTime != null ? thursdayTime.Time + "<br/>" + thursdayTime.Language : ""; fridayMass.InnerHtml = fridayTime != null ? fridayTime.Time + "<br/>" + fridayTime.Language : ""; saturdayMass.InnerHtml = saturdayTime != null ? saturdayTime.Time + "<br/>" + saturdayTime.Language : ""; row.Cells.Add(dayTime); row.Cells.Add(sundayMass); row.Cells.Add(mondayMass); row.Cells.Add(tuesdayMass); row.Cells.Add(wednesdayMass); row.Cells.Add(thursdayMass); row.Cells.Add(fridayMass); row.Cells.Add(saturdayMass); row.Attributes.Add("class", "text-center"); massScheduleTable.Rows.Add(row); } if (churches.Announcements.Count > 0) { foreach (var announcement in churches.Announcements) { var announcementControl = new Components.Announcement(announcement); churchAnnouncementContainer.InnerHtml += announcementControl.ToHtml(); } } else { churchAnnouncementContainer.InnerHtml += "<h4>No Announcement Found.</h4>"; } foreach (var review in churches.ChurchReviews) { var reviewItem = new Components.ChurchReview(review); churchReviewsContainer.InnerHtml += reviewItem.ToHtml(); } //var path = HttpContext.Current.Request.Url.AbsolutePath; //string[] QueryArray = path.Split('/'); //var newPath = QueryArray[1]; //var root = QueryArray[0]; //if (newPath == "Churches") //{ // ResolveUrl("Churches.aspx"); // var carousel = new Carousel(); // if (churches.ChurchPhotos.Count > 0) // { // //carousel.FirstImage = churches.ChurchPhotos[0].ChurchPhotos; // for (var i = 0; i < churches.ChurchPhotos.Count; i++) // carousel.AddImage(i, churches.ChurchPhotos[i].ChurchPhotos); // cssSlider.InnerHtml = carousel.ToHtml(); // } // else // { // cssSlider.InnerHtml = "<h3 class=\"text-center\">No Photos Available.</h3>"; // } //} else //{ var carousel = new Carousel(); if (churches.ChurchPhotos.Count > 0) { //carousel.FirstImage = churches.ChurchPhotos[0].ChurchPhotos; for (var i = 0; i < churches.ChurchPhotos.Count; i++) { carousel.AddImage(i, churches.ChurchPhotos[i].ChurchPhotos); } cssSlider.InnerHtml = carousel.ToHtml(); } else { cssSlider.InnerHtml = "<h3 class=\"text-center\">No Photos Available.</h3>"; } //} if (churches.AdorationPhotos.Count > 0) { for (var i = 0; i < churches.AdorationPhotos.Count; i++) { var imagePath = ResolveUrl(churches.AdorationPhotos[i]); var newLi = new HtmlGenericControl("li") { InnerHtml = "<img src=\"" + imagePath + "\" alt=\"\" title=\"\" id=\"wows1_" + i + "\" />" }; adorationImageList.Controls.Add(newLi); var newA = new HtmlGenericControl("a"); newA.Attributes.Add("href", "#"); newA.InnerHtml = "<a href=\"#\" title=\"\"><span><img src=\"" + imagePath + "\" alt=\"\" />" + (i + 1) + "</span></a>"; adorationLinkList.Controls.Add(newA); } } else { adorationImageContainer.InnerHtml = "<h3>No Photos Available</h3>"; } Master.GoogleMetaDescription = massDate; Page.Title = churches.Parish; }