Beispiel #1
0
        public static DateTime GetZman(
            DateTime date, Location location, string methodName)
        {
            ComplexZmanimCalendar czc = GetComplexZmanimCalendar(location, date);

            return(GetZmanMethodFormName(methodName, czc).ToUniversalTime());
        }
Beispiel #2
0
        private static void Main(string[] args)
        {
            options = new ZmanimOptions();

            p = new OptionSet
                    {
                        {"d|date=", "Set date. <mm/dd/yyyy>", x => options.Date = DateTime.ParseExact(x, "MM/dd/yyyy", CultureInfo.InvariantCulture)},
                        {"lat|latitude=", "Set location's latitude", (double x) => options.Latitude = x},
                        {"lon|longitude=", "Set location's longitude", (double x) => options.Longitude = x},
                        {"e|elevation=", "Set location's elevation; Positive only", (double x) => options.Elevation = x},
                        {"tz|timezone=", "Set location's TimeZone", x => options.TimeZone = x},
                        {"tf|timeformat=", "Set the way the application formats a DateTime object.", x => options.DateTimeFormat = x},
                        {"h|?|help", "Shows this help message", v => ShowHelp()}
                    };

            List<string> extraArgs;
            try
            {
                extraArgs = p.Parse(args);
            }
            catch (OptionException)
            {
                ShowHelp();
                return;
            }

            var timeZone = new OlsonTimeZone(options.TimeZone);
            var location =
                new GeoLocation(string.Empty, options.Latitude, options.Longitude, options.Elevation, timeZone);
            var czc = new ComplexZmanimCalendar(new DateTime(options.Date.Year, options.Date.Month, options.Date.Day), location);

            var methods = GetDateTimeAndLongMethods();

            foreach (var first in
                extraArgs.Select(extraArg =>
                                 methods.Where(
                                     f => f.Name.Remove(0, 3).ToLowerInvariant() == extraArg.ToLowerInvariant()).First())
                )
            {
                object invoke = first.Invoke(czc, null);

                if (extraArgs.Count > 1)
                    Console.Write(first.Name.Remove(0, 3) + ": ");

                if (invoke.GetType() == typeof(DateTime))
                {
                    var time = (DateTime)invoke;
                    Console.Write(time.ToString(options.DateTimeFormat));
                }
                else if (invoke.GetType() == typeof(long))
                {
                    Console.WriteLine((long)invoke);
                }

                if (extraArgs.Count > 1)
                    Console.WriteLine();
            }
            //Console.Read();
        }
Beispiel #3
0
        public static ComplexZmanimCalendar GetCalendar(this Location location)
        {
            var complexZmanimCalendar =
                new ComplexZmanimCalendar(new GeoLocation(location.LocationName, location.Latitude, location.Longitude,
                                                          location.Elevation,
                                                          new OlsonTimeZone(location.TimeZone)));

            return complexZmanimCalendar;
        }
Beispiel #4
0
        public static ComplexZmanimCalendar GetCalendar(this Location location)
        {
            var complexZmanimCalendar =
                new ComplexZmanimCalendar(new GeoLocation(location.LocationName, location.Latitude, location.Longitude,
                                                          location.Elevation,
                                                          new OlsonTimeZone(location.TimeZone)));

            return(complexZmanimCalendar);
        }
Beispiel #5
0
        public void Setup()
        {
            var location = new GeoLocation("Lakewood, NJ", 40.09596, -74.22213, 0, new OlsonTimeZone("America/New_York"));

            calendar = new ComplexZmanimCalendar(new DateTime(2010, 4, 2), location)
            {
                AstronomicalCalculator = new SunTimesCalculator()
            };
        }
Beispiel #6
0
        public void Will_return_null_when_trying_to_get_the_zman()
        {
            var calendar = new ComplexZmanimCalendar(
                new DateTime(2010, 5, 27),
                new GeoLocation("Gateshead, England", 54.9593729, -1.6018252, 0, new WindowsTimeZone(TimeZoneInfo.Utc))
                );

            Assert.That(calendar.GetAlos16Point1Degrees(), Is.Null);
        }
Beispiel #7
0
        public void LocalTimeConversion_should_correctly_use_time_for_daylight_saving_day_of_transition()
        {
            ITimeZone timeZone = new OlsonTimeZone("America/New_York");
            var       location = new GeoLocation("Lakewood, NJ", 40.09596, -74.22213, 0, timeZone);
            var       czc      = new ComplexZmanimCalendar(DateTime.Parse("11/3/2019"), location);

            var sunrise = czc.GetSunrise();

            Assert.That(sunrise.Value.Hour, Is.EqualTo(6));
        }
Beispiel #8
0
        public IEnumerable <ComplexZmanimCalendar> GetDaysInHebrewMonth(DateTime yearAndMonth, GeoLocation location)
        {
            Calendar calendar    = new HebrewCalendar();
            var      daysInMonth = calendar.GetDaysInMonth(calendar.GetYear(yearAndMonth), calendar.GetMonth(yearAndMonth));

            for (int i = 0; i < daysInMonth; i++)
            {
                var zmanimCalendar = new ComplexZmanimCalendar(location);
                zmanimCalendar.DateWithLocation.Date = new DateTime(yearAndMonth.Year, yearAndMonth.Month, i + 1);
                yield return(zmanimCalendar);
            }
        }
Beispiel #9
0
        public void Setup()
        {
            String                locationName = "Lakewood, NJ";
            double                latitude     = 40.09596;  //Lakewood, NJ
            double                longitude    = -74.22213; //Lakewood, NJ
            double                elevation    = 0;         //optional elevation
            ITimeZone             timeZone     = new OlsonTimeZone("America/New_York");
            GeoLocation           location     = new GeoLocation(locationName, latitude, longitude, elevation, timeZone);
            ComplexZmanimCalendar czc          = new ComplexZmanimCalendar(new DateTime(2010, 4, 2), location);

            calendar = czc;
        }
Beispiel #10
0
        public DateTime GetNextIncludedTimeUtc(DateTime timeUtc)
        {
            ComplexZmanimCalendar complexZmanimCalendar = null;

            if (timeUtc.DayOfWeek == DayOfWeek.Friday)
            {
                complexZmanimCalendar = ZmanimHelper.GetCalendar(location, timeUtc.AddDays(1));
            }
            else if (timeUtc.DayOfWeek == DayOfWeek.Saturday)
            {
                complexZmanimCalendar = ZmanimHelper.GetCalendar(location, timeUtc);
            }

            return(complexZmanimCalendar == null ? DateTime.UtcNow : complexZmanimCalendar.GetTzais().Value.ToUniversalTime());
        }
Beispiel #11
0
        public void Check_is_offset_timezone_working()
        {
            String locationName = "Lakewood, NJ";
            double latitude     = 40.09596;  //Lakewood, NJ
            double longitude    = -74.22213; //Lakewood, NJ
            double elevation    = 0;         //optional elevation
            var    timeZone     = new OffsetTimeZone(new TimeSpan(0, 0, -14400));
            var    location     = new GeoLocation(locationName, latitude, longitude, elevation, timeZone);
            var    czc          = new ComplexZmanimCalendar(new DateTime(2010, 4, 2), location);

            var zman = czc.GetSunrise();

            Assert.That(zman, Is.EqualTo(
                            new DateTime(2010, 4, 2, 6, 39, 41, 832)
                            ));
        }
Beispiel #12
0
        public static bool IsShabbos(this ComplexZmanimCalendar calendar)
        {
            bool isShabbos = false;

            var timeUtc = calendar.DateWithLocation.Date.ToUniversalTime();

            if (timeUtc.DayOfWeek == DayOfWeek.Friday)
            {
                isShabbos = timeUtc > calendar.GetCandleLighting().Value.ToUniversalTime();
            }
            if (timeUtc.DayOfWeek == DayOfWeek.Saturday)
            {
                isShabbos = timeUtc <= calendar.GetTzais().Value.ToUniversalTime();
            }

            return(isShabbos);
        }
Beispiel #13
0
        public IEnumerable <ComplexZmanimCalendar> GetDaysInHebrewYear(DateTime year, GeoLocation location)
        {
            Calendar calendar       = new HebrewCalendar();
            var      currentYear    = calendar.GetYear(year);
            var      amountOfMonths = calendar.GetMonthsInYear(currentYear);

            for (int i = 0; i < amountOfMonths; i++)
            {
                var currentMonth = i + 1;
                var daysInMonth  = calendar.GetDaysInMonth(currentYear, currentMonth);

                for (int dayOfMonth = 0; dayOfMonth < daysInMonth; dayOfMonth++)
                {
                    var zmanimCalendar = new ComplexZmanimCalendar(location);
                    zmanimCalendar.DateWithLocation.Date = new DateTime(currentYear, currentMonth, dayOfMonth + 1, calendar);
                    yield return(zmanimCalendar);
                }
            }
        }
Beispiel #14
0
        static void Main(string[] args)
        {
            string locationName = "Lakewood, NJ";
            double latitude = 40.09596; //Lakewood, NJ
            double longitude = -74.22213; //Lakewood, NJ
            double elevation = 0; //optional elevation
            ITimeZone timeZone = new OlsonTimeZone("America/New_York");
            GeoLocation location = new GeoLocation(locationName, latitude, longitude, elevation, timeZone);
            ComplexZmanimCalendar zc = new ComplexZmanimCalendar(location);

            System.Console.WriteLine("Today's Zmanim for " + locationName);
            System.Console.WriteLine("Sunrise: " + zc.GetSunrise()); //output sunrise
            System.Console.WriteLine("Sof Zman Shema MGA: " + zc.GetSofZmanShmaMGA()); //output Sof Zman Shema MGA
            System.Console.WriteLine("Sof Zman Shema GRA: " + zc.GetSofZmanShmaGRA()); //output Sof Zman Shema GRA
            System.Console.WriteLine("Sunset: " + zc.GetSunset()); //output sunset

            System.Console.WriteLine("Press enter to exit.");
            System.Console.ReadLine();
        }
Beispiel #15
0
        public static DateTime GetZmanMethodFormName(string methodName, ComplexZmanimCalendar zmanimCalendar)
        {
            if (ZmainMethods == null)
            {
                var dateType = typeof(DateTime);
                /*var longType = typeof(long);*/

                ZmainMethods = typeof(ComplexZmanimCalendar).GetMethods()
                               .Where(m => (m.ReturnType == dateType /*|| m.ReturnType == longType*/) &&
                                      m.Name.StartsWith("get") &&
                                      m.IsPublic &&
                                      m.GetParameters().Count() == 0).ToList();
            }

            var methodInfo = ZmainMethods
                             .Where(z => z.Name.ToLowerInvariant() == "get" + methodName.ToLowerInvariant()).First();

            return((DateTime)methodInfo.Invoke(zmanimCalendar, null));
        }
Beispiel #16
0
        static void Main(string[] args)
        {
            string                locationName = "Lakewood, NJ";
            double                latitude     = 40.09596;  //Lakewood, NJ
            double                longitude    = -74.22213; //Lakewood, NJ
            double                elevation    = 0;         //optional elevation
            ITimeZone             timeZone     = new OlsonTimeZone("America/New_York");
            GeoLocation           location     = new GeoLocation(locationName, latitude, longitude, elevation, timeZone);
            ComplexZmanimCalendar zc           = new ComplexZmanimCalendar(location);

            System.Console.WriteLine("Today's Zmanim for " + locationName);
            System.Console.WriteLine("Sunrise: " + zc.GetSunrise());                   //output sunrise
            System.Console.WriteLine("Sof Zman Shema MGA: " + zc.GetSofZmanShmaMGA()); //output Sof Zman Shema MGA
            System.Console.WriteLine("Sof Zman Shema GRA: " + zc.GetSofZmanShmaGRA()); //output Sof Zman Shema GRA
            System.Console.WriteLine("Sunset: " + zc.GetSunset());                     //output sunset

            System.Console.WriteLine("Press enter to exit.");
            System.Console.ReadLine();
        }
Beispiel #17
0
        public void TestSunset()
        {
            var calculator = new NOAACalculator();

            string    locationName = "Lakewood, NJ";
            double    latitude     = 40.09596;  //Lakewood, NJ
            double    longitude    = -74.22213; //Lakewood, NJ
            double    elevation    = 0;         //optional elevation
            ITimeZone timeZone     = new OlsonTimeZone("America/New_York");
            var       location     = new GeoLocation(locationName, latitude, longitude, elevation, timeZone);
            var       calendar     = new ComplexZmanimCalendar(new DateTime(2010, 4, 2), location);

            calendar.AstronomicalCalculator = calculator;

            var zman = calendar.GetSunrise();

            Assert.That(zman, Is.EqualTo(
                            new DateTime(2010, 4, 2, 6, 39, 17, 482)
                            ));
        }
Beispiel #18
0
        public ComplexZmanimCalendar GetCalendar()
        {
            String                locationName = "Lakewood, NJ";
            double                latitude     = 40.09596;  //Lakewood, NJ
            double                longitude    = -74.22213; //Lakewood, NJ
            double                elevation    = 0;         //optional elevation
            ITimeZone             timeZone     = new OlsonTimeZone("America/New_York");
            GeoLocation           location     = new GeoLocation(locationName, latitude, longitude, elevation, timeZone);
            ComplexZmanimCalendar czc          = new ComplexZmanimCalendar(new DateTime(2010, 4, 2), location);

            /*
             * string locationName = "Brooklyn, NY";
             * double latitude = 40.618851; //Brooklyn, NY
             * double longitude = -73.985921; //Brooklyn, NY
             * double elevation = 0; //optional elevation
             * TimeZone timeZone = TimeZone.getTimeZone("America/New_York");
             * var location = new GeoLocation(locationName, latitude, longitude, elevation, timeZone);
             * var czc = new ComplexZmanimCalendar(location);
             * czc.setCalendar(new GregorianCalendar(2010, 3, 2));
             */
            return(czc);
        }
        public async Task <JsonResult> Post([FromBody] GoogleJsonRequest value)
        {
            //Create request
            try
            {
                HttpContext.Request.Body.Position = 0;
                StreamReader read = new StreamReader(HttpContext.Request.Body, true);
                //log the inconming request body just to be able to view them on heroku
                Console.WriteLine(await read.ReadToEndAsync());
                WebRequest request = WebRequest.Create("http://freegeoip.net/json/" + Request.Headers["x-forwarded-for"].ToString());
                request.Method = "GET";
                //Get the response
                WebResponse wr = await request.GetResponseAsync();

                Stream       receiveStream = wr.GetResponseStream();
                StreamReader reader        = new StreamReader(receiveStream);
                string       content       = reader.ReadToEnd();
                JObject      obj           = JObject.Parse(content);
                String       city          = (String)obj["city"];
                double       lat           = (Double)obj["latitude"];
                double       lon           = (Double)obj["longitude"];
                String       timeZone      = (String)obj["time_zone"];
                //generate the zmanim
                ITimeZone   zmanimTimeZone = new WindowsTimeZone(timeZone);
                GeoLocation location       = new GeoLocation("Random", lat, lon,
                                                             0, zmanimTimeZone);
                ComplexZmanimCalendar czc = new ComplexZmanimCalendar(location);
                //if zmanim_names is null then return the full zmanim, otherwise return that specific zman
                if (value is null || value.Result is null || value.Result.Parameters is null || value.Result.Parameters.ZmanimNames is null)
                {
                    String Speech = "Here are your jewish times for " + city + ". Dawn is at " + czc.GetAlosHashachar().formatDate() + ". Sunrise is at " + czc.GetSunrise().formatDate()
                                    + ". The Latest Shema is at " + czc.GetSofZmanShmaMGA().formatDate() + " According to the magein avraham, and at "
                                    + czc.GetSofZmanShmaGRA().formatDate() + " according to the grah." + " The latest time for morning prayers is at "
                                    + czc.GetSofZmanTfilaGRA().formatDate() + " According to the grah and at "
                                    + czc.GetSofZmanShmaMGA().formatDate() + " according to the magein avraham. "
                                    + "Midday is at " + czc.GetChatzos().formatDate() + ". The earliest time for afternoon services is at " + czc.GetMinchaGedola().formatDate()
                                    + ". Sunset is at" + czc.GetSunset().formatDate()
                                    + ". Nightfall is at " + czc.GetTzais().formatDate();

                    String display =
                        "Jewish times for " + city + "\nDawn-" + czc.GetAlosHashachar().formatDate() + "\nSunrise-" + czc.GetSunrise().formatDate()
                        + "\n Latest Shema MGA-" + czc.GetSofZmanShmaMGA().formatDate() + "\n Latest Shema Gra-"
                        + czc.GetSofZmanShmaGRA().formatDate() + "\nLatest morning prayers Gra-"
                        + czc.GetSofZmanTfilaGRA().formatDate() + "\nLatest morning prayers Mga-"
                        + czc.GetSofZmanShmaMGA().formatDate()
                        + "\nMidday-" + czc.GetChatzos().formatDate() + "\nEarliest afternoon prayers-" + czc.GetMinchaGedola().formatDate()
                        + "\nSunset-" + czc.GetSunset().formatDate()
                        + "\nNightfall-" + czc.GetTzais().formatDate();

                    ResponseJson response = new ResponseJson();
                    response.DisplayText = display;
                    response.Source      = "Zmanim.net";
                    response.Speech      = Speech;
                    Console.WriteLine("Processed post method");
                    return(Json(response));
                }
                else
                {
                    String speech  = "";
                    String display = "";
                    switch (value.Result.Parameters.ZmanimNames)
                    {
                    case "shkia":
                        speech  = "Sunset is at " + czc.GetSunset().formatDate();
                        display = speech;
                        break;

                    case "sofeshema":
                        speech  = "Latest shema is at " + czc.GetSofZmanShmaGRA().formatDate() + " according to the grah, and at " + czc.GetSofZmanShmaMGA().formatDate() + " according to the magein avraham";
                        display = "Latest Shema Gra: " + czc.GetSofZmanShmaGRA().formatDate() + ". Latest Shema Magein Avraham: " + czc.GetSofZmanShmaMGA().formatDate();
                        break;

                    case "sofeteffilah":
                        speech  = "The latest time for morning prayers is at " + czc.GetSofZmanTfilaGRA().formatDate() + " according to the grah, and at " + czc.GetSofZmanTfilaMGA().formatDate() + " according to the magein avraham";
                        display = "Latest morning prayers Gra: " + czc.GetSofZmanTfilaGRA().formatDate() + ". Latest morning prayers Magein Avraham: " + czc.GetSofZmanTfilaMGA().formatDate();
                        break;

                    case "chatzos":
                        speech  = "Midday is at " + czc.GetChatzos().formatDate();
                        display = speech;
                        break;

                    case "minchagedolah":
                        speech  = "The earliest time for afternoon prayer is at " + czc.GetMinchaGedola().formatDate();
                        display = speech;
                        break;

                    case "minchaketana":
                        speech  = "Mincha Ketana is at " + czc.GetMinchaKetana().formatDate();
                        display = speech;
                        break;

                    case "neitz":
                        speech  = "Sunrise is at " + czc.GetSunrise().formatDate();
                        display = speech;
                        break;

                    case "alos":
                        speech  = "Dawn is at " + czc.GetAlosHashachar().formatDate();
                        display = speech;
                        break;

                    case "tzaishakochavim":
                        speech  = "Nightfall is at " + czc.GetTzais().formatDate();
                        display = speech;
                        break;

                    default:
                        speech  = "The zman you requested could not be calculated";
                        display = speech;
                        break;
                    }
                    ResponseJson response = new ResponseJson();
                    response.DisplayText = display + " in " + city;
                    response.Source      = "Zmanim.net";
                    response.Speech      = speech + " in " + city;
                    Console.WriteLine("Processed post method");
                    return(Json(response));
                }
            }
        public ZmanimService(ZmanimModel model)
        {
            String      locationName = "Random";
            double      latitude     = model.latitude;
            double      longitude    = model.longitude;
            double      elevation    = model.elevation;
            ITimeZone   timeZone     = new WindowsTimeZone(model.timezone);
            GeoLocation location     = new GeoLocation(locationName, latitude, longitude,
                                                       elevation, timeZone);
            ComplexZmanimCalendar czc;

            //if the models date is null then set the models date to today
            if (!model.date.HasValue)
            {
                model.date = DateTime.Now;
            }
            Console.WriteLine("Date was submitted so using the date of" + model.date.ToString());
            czc = new ComplexZmanimCalendar(model.date.GetValueOrDefault(), location);
            //If the request wanted basic mode then use basic zmanim, else print everything
            if (model.mode == "basic")
            {
                //insert the zmanim into the model so the controller can create a view from it
                model.zmanimList.Add("Alos 16point 1Degrees", czc.GetAlos16Point1Degrees());
                model.zmanimList.Add("Sunrise", czc.GetSunrise());
                model.zmanimList.Add("Sof Zman Shema MGA", czc.GetSofZmanShmaMGA());
                model.zmanimList.Add("Sof Zman Shema Gra", czc.GetSofZmanShmaGRA());
                model.zmanimList.Add("Sof Zman Tefilah Gra", czc.GetSofZmanTfilaGRA());
                model.zmanimList.Add("Sof Zman Tefilah MGA", czc.GetSofZmanTfilaMGA72Minutes());
                model.zmanimList.Add("Chatzos", czc.GetChatzos());
                model.zmanimList.Add("Mincha Gedolah", czc.GetMinchaGedola());
                model.zmanimList.Add("PlagHamincha", czc.GetPlagHamincha());
                model.zmanimList.Add("Shkia", czc.GetSunset());
                model.zmanimList.Add("Tzais", czc.GetTzais());
                model.zmanimList.Add("Candle Lighting", czc.GetCandleLighting());
            }
            else
            {
                //insert the zmanim into the model so the controller can create a view from it
                model.zmanimList.Add("Alos", czc.GetAlos16Point1Degrees());
                model.zmanimList.Add("Alos16point1Degrees", czc.GetAlos16Point1Degrees());
                model.zmanimList.Add("Alos18Degrees", czc.GetAlos18Degrees());
                model.zmanimList.Add("Alos19Point8Degrees", czc.GetAlos19Point8Degrees());
                model.zmanimList.Add("Alos26Degrees", czc.GetAlos26Degrees());
                model.zmanimList.Add("Alos60", czc.GetAlos60());
                model.zmanimList.Add("Alos72", czc.GetAlos72Zmanis());
                model.zmanimList.Add("Alos90", czc.GetAlos90());
                model.zmanimList.Add("Alos90Zmanim", czc.GetAlos90Zmanis());
                model.zmanimList.Add("Alos96", czc.GetAlos96());
                model.zmanimList.Add("Alos96Zmanim", czc.GetAlos96Zmanis());
                model.zmanimList.Add("Alos120", czc.GetAlos120());
                model.zmanimList.Add("Alos120Zmanim", czc.GetAlos120Zmanis());
                model.zmanimList.Add("Misheyakir10.2Degrees", czc.GetMisheyakir10Point2Degrees());
                model.zmanimList.Add("Misheyakir11Degrees", czc.GetMisheyakir11Degrees());
                model.zmanimList.Add("Misheyakir11.5Degrees", czc.GetMisheyakir11Point5Degrees());
                model.zmanimList.Add("Sunrise", czc.GetSunrise());
                model.zmanimList.Add("SofZmanShemaMGA", czc.GetSofZmanShmaMGA());
                model.zmanimList.Add("SofZmanShmaGra", czc.GetSofZmanShmaGRA());
                model.zmanimList.Add("SofZmanShema3HoursBeforeChatzos", czc.GetSofZmanShma3HoursBeforeChatzos());
                model.zmanimList.Add("SofZmanShemaAlos16Point1ToSunset", czc.GetSofZmanShmaAlos16Point1ToSunset());
                model.zmanimList.Add("SofZmanShemaAlos16Point1ToTzaisGeonim7Point083Degrees", czc.GetSofZmanShmaAlos16Point1ToTzaisGeonim7Point083Degrees());
                model.zmanimList.Add("SofZmanShemaAteretTorah", czc.GetSofZmanShmaAteretTorah());
                model.zmanimList.Add("SofZmanShemaMGA18Degrees", czc.GetSofZmanShmaMGA18Degrees());
                model.zmanimList.Add("SofZmanShemaMGA16Point1Degrees", czc.GetSofZmanShmaMGA16Point1Degrees());
                model.zmanimList.Add("SofZmanShemaMGA19point8Degrees", czc.GetSofZmanShmaMGA19Point8Degrees());
                model.zmanimList.Add("SofZmanShemaMGA72", czc.GetSofZmanShmaMGA72Minutes());
                model.zmanimList.Add("SofZmanShemaMGA72Zmanis", czc.GetSofZmanShmaMGA72MinutesZmanis());
                model.zmanimList.Add("SofZmanShemaMGA90", czc.GetSofZmanShmaMGA90Minutes());
                model.zmanimList.Add("SofZmanShemaMGA90Zmanis", czc.GetSofZmanShmaMGA90MinutesZmanis());
                model.zmanimList.Add("SofZmanShemaMGA96", czc.GetSofZmanShmaMGA96Minutes());
                model.zmanimList.Add("SofZmanShemaMGA96Zmanis", czc.GetSofZmanShmaMGA96MinutesZmanis());
                model.zmanimList.Add("SofZmanShemaMGA120", czc.GetSofZmanShmaMGA120Minutes());
                model.zmanimList.Add("SofZmanTefilahGra", czc.GetSofZmanTfilaGRA());
                model.zmanimList.Add("SofZmanTefilahGra2HoursBeforeChatzos", czc.GetSofZmanTfila2HoursBeforeChatzos());
                model.zmanimList.Add("SofZmanTefilahAteretTorah", czc.GetSofZmanTfilahAteretTorah());
                model.zmanimList.Add("SofZmanTefilahMGA72", czc.GetSofZmanTfilaMGA72Minutes());
                model.zmanimList.Add("SofZmanTefilahMGA72Zmanis", czc.GetSofZmanTfilaMGA72MinutesZmanis());
                model.zmanimList.Add("SofZmanTefilahMGA90", czc.GetSofZmanTfilaMGA90Minutes());
                model.zmanimList.Add("SofZmanTefilahMGA90Zmanis", czc.GetSofZmanTfilaMGA90MinutesZmanis());
                model.zmanimList.Add("SofZmanTefilahMGA96", czc.GetSofZmanTfilaMGA96Minutes());
                model.zmanimList.Add("SofZmanTefilahMGA96Zmanis", czc.GetSofZmanTfilaMGA96MinutesZmanis());
                model.zmanimList.Add("SofZmanTefilahMGA120", czc.GetSofZmanTfilaMGA120Minutes());
                model.zmanimList.Add("SolarMidnight", czc.GetSolarMidnight());
                model.zmanimList.Add("Chatzos", czc.GetChatzos());
                model.zmanimList.Add("MinchaGedolah", czc.GetMinchaGedola());
                model.zmanimList.Add("MinchaGedolah16.1Degrees", czc.GetMinchaGedola16Point1Degrees());
                model.zmanimList.Add("MinchaGedolah30MinutesAfterChatzos", czc.GetMinchaGedola30Minutes());
                model.zmanimList.Add("MinchaGedolah72MinutesAfterChatzos", czc.GetMinchaGedola72Minutes());
                model.zmanimList.Add("MinchaGedolahAteretTorah", czc.GetMinchaGedolaAteretTorah());
                model.zmanimList.Add("MinchaKetana", czc.GetMinchaKetana());
                model.zmanimList.Add("MinchaKetanaMGA72Minutes", czc.GetMinchaKetana72Minutes());
                model.zmanimList.Add("MinchaKetanaMGA16.1Degrees", czc.GetMinchaKetana16Point1Degrees());
                model.zmanimList.Add("MinchaKetanaAteretTorah", czc.GetMinchaKetanaAteretTorah());
                model.zmanimList.Add("PlagHamincha", czc.GetPlagHamincha());
                model.zmanimList.Add("PlagHaminchaAteretTorah", czc.GetPlagHaminchaAteretTorah());
                model.zmanimList.Add("PlagHaminchaDayStartAlosEndSunset", czc.GetPlagAlosToSunset());
                model.zmanimList.Add("PlagHaminchaAlos16Point1ToTzaisGeonim7Point083Degrees", czc.GetPlagAlos16Point1ToTzaisGeonim7Point083Degrees());
                model.zmanimList.Add("PlagHamincha18Degrees", czc.GetPlagHamincha18Degrees());
                model.zmanimList.Add("PlagHamincha19.8Degrees", czc.GetPlagHamincha19Point8Degrees());
                model.zmanimList.Add("PlagHamincha26Degrees", czc.GetPlagHamincha26Degrees());
                model.zmanimList.Add("PlagHamincha60", czc.GetPlagHamincha60Minutes());
                model.zmanimList.Add("PlagHamincha72", czc.GetPlagHamincha72Minutes());
                model.zmanimList.Add("PlagHamincha72Zmanis", czc.GetPlagHamincha72MinutesZmanis());
                model.zmanimList.Add("PlagHamincha90", czc.GetPlagHamincha90Minutes());
                model.zmanimList.Add("PlagHamincha90Zmanis", czc.GetPlagHamincha90MinutesZmanis());
                model.zmanimList.Add("PlagHamincha96", czc.GetPlagHamincha96Minutes());
                model.zmanimList.Add("PlagHamincha96Zmanis", czc.GetPlagHamincha96MinutesZmanis());
                model.zmanimList.Add("Shkia", czc.GetSunset());
                model.zmanimList.Add("BainHashmashosRabeinuTam2Stars", czc.GetBainHasmashosRT2Stars());
                model.zmanimList.Add("BainHashmashosRabeinuTam58.5Minutes", czc.GetBainHasmashosRT58Point5Minutes());
                model.zmanimList.Add("BainHashmashosRabeinuTam13.24Degrees", czc.GetBainHasmashosRT13Point24Degrees());
                model.zmanimList.Add("BainHashmashosRabeinuTam13Point5MinutesBefore7Point083Degrees", czc.GetBainHasmashosRT13Point5MinutesBefore7Point083Degrees());
                model.zmanimList.Add("Tzais", czc.GetTzais());
                model.zmanimList.Add("Tzais16.1Degrees", czc.GetTzais16Point1Degrees());
                model.zmanimList.Add("Tzais18Degrees", czc.GetTzais18Degrees());
                model.zmanimList.Add("Tzais26Degrees", czc.GetTzais26Degrees());
                model.zmanimList.Add("Tzais19.8Degrees", czc.GetTzais19Point8Degrees());
                model.zmanimList.Add("Tzais60", czc.GetTzais60());
                model.zmanimList.Add("Tzais90", czc.GetTzais90());
                model.zmanimList.Add("Tzais96", czc.GetTzais96());
                model.zmanimList.Add("Tzais120", czc.GetTzais120());
                model.zmanimList.Add("Tzais72Zmanis", czc.GetTzais72Zmanis());
                model.zmanimList.Add("Tzais90Zmanis", czc.GetTzais90Zmanis());
                model.zmanimList.Add("Tzais96Zmanis", czc.GetTzais96Zmanis());
                model.zmanimList.Add("Tzais120Zmanis", czc.GetTzais120Zmanis());
                model.zmanimList.Add("TzaisAteretTorah", czc.GetTzaisAteretTorah());
                model.zmanimList.Add("CandleLighting", czc.GetCandleLighting());
            }
        }
Beispiel #21
0
 public MainPageViewModel(ComplexZmanimCalendar zmanimCalendar)
 {
     ZmanimCalendar = zmanimCalendar;
     Zmanim = new Zmanim(zmanimCalendar);
 }
Beispiel #22
0
 public Zmanim(ComplexZmanimCalendar zmanimCalendar)
 {
     ZmanimCalendar = zmanimCalendar;
 }
Beispiel #23
0
 public Zmanim(ComplexZmanimCalendar zmanimCalendar)
 {
     ZmanimCalendar = zmanimCalendar;
 }
Beispiel #24
0
        private static void Main(string[] args)
        {
            options = new ZmanimOptions();

            p = new OptionSet
            {
                { "d|date=", "Set date. <mm/dd/yyyy>", x => options.Date = DateTime.ParseExact(x, "MM/dd/yyyy", CultureInfo.InvariantCulture) },
                { "lat|latitude=", "Set location's latitude", (double x) => options.Latitude = x },
                { "lon|longitude=", "Set location's longitude", (double x) => options.Longitude = x },
                { "e|elevation=", "Set location's elevation; Positive only", (double x) => options.Elevation = x },
                { "tz|timezone=", "Set location's TimeZone", x => options.TimeZone = x },
                { "tf|timeformat=", "Set the way the application formats a DateTime object.", x => options.DateTimeFormat = x },
                { "h|?|help", "Shows this help message", v => ShowHelp() }
            };

            List <string> extraArgs;

            try
            {
                extraArgs = p.Parse(args);
            }
            catch (OptionException)
            {
                ShowHelp();
                return;
            }

            var timeZone = new OlsonTimeZone(options.TimeZone);
            var location =
                new GeoLocation(string.Empty, options.Latitude, options.Longitude, options.Elevation, timeZone);
            var czc = new ComplexZmanimCalendar(new DateTime(options.Date.Year, options.Date.Month, options.Date.Day), location);

            var methods = GetDateTimeAndLongMethods();

            foreach (var first in
                     extraArgs.Select(extraArg =>
                                      methods.Where(
                                          f => f.Name.Remove(0, 3).ToLowerInvariant() == extraArg.ToLowerInvariant()).First())
                     )
            {
                object invoke = first.Invoke(czc, null);

                if (extraArgs.Count > 1)
                {
                    Console.Write(first.Name.Remove(0, 3) + ": ");
                }

                if (invoke.GetType() == typeof(DateTime))
                {
                    var time = (DateTime)invoke;
                    Console.Write(time.ToString(options.DateTimeFormat));
                }
                else if (invoke.GetType() == typeof(long))
                {
                    Console.WriteLine((long)invoke);
                }

                if (extraArgs.Count > 1)
                {
                    Console.WriteLine();
                }
            }
            //Console.Read();
        }
Beispiel #25
0
 public static ComplexZmanimCalendar SetCalendarDate(this ComplexZmanimCalendar calendar, DateTime date)
 {
     calendar.DateWithLocation = new DateWithLocation(new DateTime(date.Date.Year, date.Date.Month, date.Date.Day), calendar.DateWithLocation.Location);
     return(calendar);
 }
Beispiel #26
0
 public MainPageViewModel(ComplexZmanimCalendar zmanimCalendar)
 {
     ZmanimCalendar = zmanimCalendar;
     Zmanim         = new Zmanim(zmanimCalendar);
 }
Beispiel #27
0
        /// <summary>
        /// show Times Based of Geo location
        /// </summary>
        public void LocationTimes()
        {
            string      locationName;
            double      latitude;
            double      longitude;
            double      elevation;
            XmlDocument xmlDoc = new XmlDocument();

            if (!File.Exists("GeoLocation.xml"))
            {
                GeoLocationTimes glt = new GeoLocationTimes();
                glt.CreateFirstGeoLocationXML();
                //glt.SetGeoLocation();
            }
            else
            {
                xmlDoc.Load("GeoLocation.xml");
                XmlNodeList nodeList = xmlDoc.DocumentElement.SelectNodes("/Table/Geo");
                string      GeoID = "", GeoLocationName = "", Geolatitude = "", Geolongitude = "", Geoelevation = "";
                foreach (XmlNode node in nodeList)
                {
                    GeoID           = node.SelectSingleNode("Geo_Id").InnerText;
                    GeoLocationName = node.SelectSingleNode("Geo_Location_Name").InnerText;
                    Geolatitude     = node.SelectSingleNode("Latitude").InnerText;
                    Geolongitude    = node.SelectSingleNode("Longitude").InnerText;
                    Geoelevation    = node.SelectSingleNode("Elevation").InnerText;
                }
                locationName = GeoLocationName;
                latitude     = Convert.ToDouble(Geolatitude);
                longitude    = Convert.ToDouble(Geolongitude);
                elevation    = Convert.ToDouble(Geoelevation);

                //ITimeZone timeZone = new OlsonTimeZone(PublicDomain.TzTimeZone.CurrentTimeZone);
                ITimeZone             timeZone = new OlsonTimeZone("Asia/Jerusalem");
                GeoLocation           location = new GeoLocation(locationName, latitude, longitude, elevation, timeZone);
                ComplexZmanimCalendar zc = new ComplexZmanimCalendar(DateTime.Now, location);
                string   TimeFormat = "HH:mm:ss";
                DateTime d1, d2, d3, d4, d5, d6, d7, d8, d9;
                {
                    lblTi1.Text = (locationName);
                    d1          = (zc.GetAlosHashachar().Value);
                    d2          = (zc.GetBeginNauticalTwilight().Value);
                    d3          = (zc.GetSunrise().Value);
                    d4          = (zc.GetSofZmanShmaMGA().Value);
                    d5          = (zc.GetSofZmanShmaGRA().Value);
                    d6          = (zc.GetMinchaGedola72Minutes().Value);
                    d7          = (zc.GetSeaLevelSunset().Value);
                    d8          = (zc.GetTzaisGeonim4Point37Degrees().Value);
                    d9          = (zc.GetCandleLighting().Value);
                    lblTi2.Text = d1.ToString(TimeFormat);
                    lblTi3.Text = d2.ToString(TimeFormat);
                    lblTi4.Text = d3.ToString(TimeFormat);
                    lblTi5.Text = d4.ToString(TimeFormat);
                    lblTi6.Text = d5.ToString(TimeFormat);
                    lblTi7.Text = d6.ToString(TimeFormat);
                    lblTi8.Text = d7.ToString(TimeFormat);
                    //lblTi9.Text = (zc.GetTzaisGeonim8Point5Degrees().ToString());
                    //lblTi9.Text = (zc.GetTzaisGeonim3Point65Degrees().ToString());
                    lblTi9.Text     = d8.ToString(TimeFormat);
                    lblCandles.Text = d9.ToString(TimeFormat);
                }
            }
        }