Esempio n. 1
0
        /// <summary>
        /// Creates a new object that is a copy of the current instance.
        /// <b>Note:</b> If the <seealso cref="Zmanim.TimeZone.ITimeZone"/> in the cloned
        /// <see cref="GeoLocation"/> will be changed from the
        /// original, it is critical that
        /// <see cref="DateWithLocation"/>.
        /// <see cref="TimeZone">TimeZone</see>
        /// be set in order for the AstronomicalCalendar to output times in the
        /// expected offset after being cloned.
        /// </summary>
        /// <returns>
        /// A new object that is a copy of this instance.
        /// </returns>
        public virtual object Clone()
        {
            var clone = (AstronomicalCalendar)MemberwiseClone();

            clone.DateWithLocation       = (IDateWithLocation)DateWithLocation.Clone();
            clone.AstronomicalCalculator = (AstronomicalCalculator)AstronomicalCalculator.Clone();
            return(clone);
        }
Esempio n. 2
0
        public void GetPlanetRasiSignTest()
        {
            var endStdTime = DateTimeOffset.ParseExact("06:42 16/04/2021 +08:00", Time.GetDateTimeFormat(), null);
            var geoLocation = new GeoLocation("Ipoh", 101, 4.59);
            var birthTime = new Time(endStdTime, geoLocation);


            AstronomicalCalculator.GetPlanetRasiSign(PlanetName.Mercury, birthTime);
        }
Esempio n. 3
0
        public void CountFromSignToSignTest()
        {
            //test
            var count = AstronomicalCalculator.CountFromSignToSign(ZodiacName.Aquarius, ZodiacName.Taurus);

            //correct result is 4
            Assert.IsTrue(count == 4);

        }
Esempio n. 4
0
        /// <summary>
        /// Returns a hash code for this instance.
        /// </summary>
        /// <returns>
        /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
        /// </returns>
        public override int GetHashCode()
        {
            int result = 17;

            result  = 37 * result + GetType().GetHashCode(); // needed or this and subclasses will return identical hash
            result += 37 * result + DateWithLocation.GetHashCode();
            result += 37 * result + DateWithLocation.Location.GetHashCode();
            result += 37 * result + AstronomicalCalculator.GetHashCode();
            return(result);
        }
Esempio n. 5
0
        public void GetLongitudeAtZodiacSignTest()
        {
            //TEST 190 = 10 in Libra
            var libra10 = new ZodiacSign(ZodiacName.Libra, Angle.FromDegrees(10));
            var longitude = AstronomicalCalculator.GetLongitudeAtZodiacSign(libra10);
            var testSign = AstronomicalCalculator.GetZodiacSignAtLongitude(longitude);

            var expected = libra10.GetDegreesInSign().TotalDegrees;
            var actual = testSign.GetDegreesInSign().TotalDegrees;

            Assert.AreEqual(expected, actual);
        }
Esempio n. 6
0
        public void GetLunarMonthTest4()
        {

            var endStdTime = DateTimeOffset.ParseExact("15:00 01/01/2020 +08:00", Time.GetDateTimeFormat(), null);
            var geoLocation = new GeoLocation("Ipoh", 101, 4.59);
            var time = new Time(endStdTime, geoLocation);

            var lunarMonthTest = AstronomicalCalculator.GetLunarMonth(time);

            var lunarMonthCorrect = LunarMonth.Pooshiam;

            Assert.AreEqual(lunarMonthCorrect, lunarMonthTest);
        }
Esempio n. 7
0
        /// <summary>
        /// Determines whether the specified <see cref="System.Object"/> is equal to this instance.
        /// </summary>
        /// <param name="obj">The <see cref="System.Object"/> to compare with this instance.</param>
        /// <returns>
        ///     <c>true</c> if the specified <see cref="System.Object"/> is equal to this instance; otherwise, <c>false</c>.
        /// </returns>
        /// <exception cref="T:System.NullReferenceException">
        /// The <paramref name="obj"/> parameter is null.
        /// </exception>
        public override bool Equals(object obj)
        {
            if (this == obj)
            {
                return(true);
            }
            if (!(obj is AstronomicalCalendar))
            {
                return(false);
            }
            var aCal = (AstronomicalCalendar)obj;

            return(DateWithLocation.Equals(aCal.DateWithLocation) && DateWithLocation.Location.Equals(aCal.DateWithLocation.Location) &&
                   AstronomicalCalculator.Equals(aCal.AstronomicalCalculator));
        }
Esempio n. 8
0
        /// <summary>
        /// Determines whether the specified <see cref="System.Object"/> is equal to this instance.
        /// </summary>
        /// <param name="obj">The <see cref="System.Object"/> to compare with this instance.</param>
        /// <returns>
        ///     <c>true</c> if the specified <see cref="System.Object"/> is equal to this instance; otherwise, <c>false</c>.
        /// </returns>
        /// <exception cref="T:System.NullReferenceException">
        /// The <paramref name="obj"/> parameter is null.
        /// </exception>
        public override bool Equals(object obj)
        {
            if (this == obj)
            {
                return(true);
            }
            if (!(obj is ZmanimCalendar))
            {
                return(false);
            }
            var zCal = (ZmanimCalendar)obj;

            // return getCalendar().ToMillisecondsFromEpoch().equals(zCal.getCalendar().ToMillisecondsFromEpoch())
            return(DateWithLocation.Equals(zCal.DateWithLocation) && DateWithLocation.Location.Equals(zCal.DateWithLocation.Location) &&
                   AstronomicalCalculator.Equals(zCal.AstronomicalCalculator));
        }
Esempio n. 9
0
 /// <summary>
 /// Method that returns the sunset in UTC time without correction for
 /// elevation, time zone offset from GMT and without using daylight savings
 /// time. Non-sunrise and sunset calculations such as dawn and dusk, depend
 /// on the amount of visible light, something that is not affected by
 /// elevation. This method returns UTC sunset calculated at sea level. This
 /// forms the base for dusk calculations that are calculated as a dip below
 /// the horizon after sunset.
 /// </summary>
 /// <param name="zenith">the degrees below the horizon. For time before sunset use
 /// negative numbers.</param>
 /// <returns>
 /// The time in the format: 18.75 for 18:45:00 UTC/GMT.
 /// If the calculation can't be computed such as in the Arctic Circle where
 /// there is at least one day a year where the sun does not rise, and
 /// one where it does not set, <see cref="Double.NaN"/> will be returned.
 /// See detailed explanation on top of the page.
 /// </returns>
 /// <seealso cref="GetUtcSunset"/>
 /// <seealso cref="GetUtcSeaLevelSunrise"/>
 public virtual double GetUtcSeaLevelSunset(double zenith)
 {
     return(AstronomicalCalculator.GetUtcSunset(DateWithLocation, zenith, false));
 }
Esempio n. 10
0
 /// <summary>
 /// Method that returns the sunrise in UTC time without correction for time
 /// zone offset from GMT and without using daylight savings time.
 /// </summary>
 /// <param name="zenith">the degrees below the horizon. For time after sunrise use
 /// negative numbers.</param>
 /// <returns>
 /// The time in the format: 18.75 for 18:45:00 UTC/GMT.
 /// If the calculation can't be computed such as in the Arctic Circle where
 /// there is at least one day a year where the sun does not rise, and
 /// one where it does not set, <see cref="Double.NaN"/> will be returned.
 /// See detailed explanation on top of the page.
 /// </returns>
 public virtual double GetUtcSunrise(double zenith)
 {
     return(AstronomicalCalculator.GetUtcSunrise(DateWithLocation, zenith, true));
 }
Esempio n. 11
0
 /// <summary>
 /// Method that returns the sunset in UTC time without correction for
 /// elevation, time zone offset from GMT and without using daylight savings
 /// time. Non-sunrise and sunset calculations such as dawn and dusk, depend
 /// on the amount of visible light, something that is not affected by
 /// elevation. This method returns UTC sunset calculated at sea level. This
 /// forms the base for dusk calculations that are calculated as a dip below
 /// the horizon after sunset.
 /// </summary>
 /// <param name="zenith">the degrees below the horizon. For time before sunset use
 /// negative numbers.</param>
 /// <returns>
 /// The time in the format: 18.75 for 18:45:00 UTC/GMT.
 /// If the calculation can't be computed such as in the Arctic Circle where
 /// there is at least one day a year where the sun does not rise, and
 /// one where it does not set, <see cref="Double.NaN"/> will be returned.
 /// See detailed explanation on top of the page.
 /// </returns>
 /// <seealso cref="GetUtcSunset"/>
 /// <seealso cref="GetUtcSeaLevelSunrise"/>
 public virtual double GetUtcSeaLevelSunset(double zenith)
 {
     return(AstronomicalCalculator.GetUtcSunset(this, zenith, false));
 }
Esempio n. 12
0
 /// <summary>
 /// Method that returns the sunrise in UTC time without correction for time
 /// zone offset from GMT and without using daylight savings time.
 /// </summary>
 /// <param name="zenith">the degrees below the horizon. For time after sunrise use
 /// negative numbers.</param>
 /// <returns>
 /// The time in the format: 18.75 for 18:45:00 UTC/GMT.
 /// If the calculation can't be computed such as in the Arctic Circle where
 /// there is at least one day a year where the sun does not rise, and
 /// one where it does not set, <see cref="Double.NaN"/> will be returned.
 /// See detailed explanation on top of the page.
 /// </returns>
 public virtual double GetUtcSunrise(double zenith)
 {
     return(AstronomicalCalculator.GetUtcSunrise(this, zenith, true));
 }