Exemplo n.º 1
0
        //--------------------------------------------------------------------------------------------
        // ----------------Local ML, PL and Refining Calculation Functions----------------

        /// <summary>Used to calculate Production Level from avalable in-form info</summary>
        private void CalculatePL()
        {
            lvPLResults.Items.Clear();  //Clear PL Results list
            // -Define local variables
            double PL = 0;
            double CurrentTime = 0, LastTime = 0;
            double RawNumber     = 0;
            double BaseTime      = m_TotalSeconds;
            double IndustrySkill = cbInustrySkill.SelectedIndex;

            // ---Calculate first PL  (PL = 0)
            RawNumber  = (1 - (PL / (PL + 1) * 0.2));                                  //PL Effect
            RawNumber *= (1 - (IndustrySkill * 0.04));                                 //Industry Skill Effect
            RawNumber *= BaseTime;                                                     //Base Time in Seconds

            lvPLResults.BeginUpdate();                                                 // State that we're begining an update

            LastTime = Math.Truncate(RawNumber);                                       //Store PL 0 as LastTime
            ListViewItem lvItem = new ListViewItem(PL.ToString("#,##0"));              // Create a new ListViewItem, add PL

            lvItem.SubItems.Add(TimeFormats.SecondsToTime((uint)LastTime).ToString()); // Add sub item Time
            lvPLResults.Items.Add(lvItem);                                             // Add ListVeiwItem to PL Results

            // ---PL Caluclation Loop for MaxPLLoops
            for (PL = 1; PL < MaxPLLoops; PL++)
            {
                RawNumber  = (1 - (PL / (PL + 1) * 0.2));  //PL Effect
                RawNumber *= (1 - (IndustrySkill * 0.04)); //Industry Skill Effect
                RawNumber *= BaseTime;                     //Base Time in Seconds

                CurrentTime = Math.Truncate(RawNumber);    //Store current PL as CurrentTime
                if (CurrentTime < LastTime)
                {
                    // ---If CurrentTime is less than LastTime, Store results in PL Results and update LastTime
                    lvItem = new ListViewItem(PL.ToString("#,##0"));                              // Create a new ListViewItem, add PL
                    lvItem.SubItems.Add(TimeFormats.SecondsToTime((uint)CurrentTime).ToString()); // Add sub item Time
                    lvPLResults.Items.Add(lvItem);                                                // Add ListVeiwItem to PL Results

                    LastTime = CurrentTime;
                }
            } // ---End PL Calculation Loop

            chPLValue.Width = 55;  // Resize PL column header Width

            // ---Check what column width to set (Content or Minimum Header Width: 35)
            chPLTime.AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent);
            int ColumnContentWidth = chPLTime.Width;
            int HeaderSize         = 40;

            if (ColumnContentWidth > HeaderSize)
            {
                chPLTime.AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent);
            }
            else
            {
                chPLTime.Width = HeaderSize;
            }

            lvPLResults.EndUpdate();  // Update over, unlock the control
        }
        public static string[] ExtractArrayTimeFromArray(ushort[] ParamRTU, TimeFormats TimeF)
        {
            if (TimeF == TimeFormats.STMFormat)
            {
                string[] strs = new string[6];
                if (ParamRTU.Length != 4)
                {
                    throw new Exception("Invalid data!");
                }

                strs[0] = (ParamRTU[3] & 0x00FF).ToString("X2");
                strs[1] = ((ParamRTU[2] >> 8) & 0x00FF).ToString("X2");
                strs[2] = (ParamRTU[2] & 0x00FF).ToString("X2");
                strs[3] = (ParamRTU[0] & 0x003F).ToString("X2");
                strs[4] = ((ParamRTU[0] >> 8) & 0x001F).ToString("X2");
                strs[5] = "20" + (ParamRTU[1] & 0x00FF).ToString("X2");
                return(strs);
            }
            else if (TimeF == TimeFormats.ADSPFormat)
            {
                string[] strs = new string[6];
                if (ParamRTU.Length != 7)
                {
                    throw new Exception("Invalid data!");
                }

                string str = "";
                str = str + (ParamRTU[2] & 0x00FF).ToString("X2") + ":";
                str = str + (ParamRTU[1] & 0x00FF).ToString("X2") + ":" + (ParamRTU[0] & 0x00FF).ToString("X2") + " ";

                str = str + (ParamRTU[4] & 0x00FF).ToString("X2") + "/" + (ParamRTU[5] & 0x001F).ToString("X2") + "/";
                str = str + "20" + (ParamRTU[6] & 0x00FF).ToString("X2");

                strs[0] = (ParamRTU[2] & 0x00FF).ToString("X2");
                strs[1] = (ParamRTU[1] & 0x00FF).ToString("X2");
                strs[2] = (ParamRTU[0] & 0x00FF).ToString("X2");
                strs[3] = (ParamRTU[4] & 0x00FF).ToString("X2");
                strs[4] = (ParamRTU[5] & 0x001F).ToString("X2");
                strs[5] = "20" + (ParamRTU[6] & 0x00FF).ToString("X2");
                return(strs);
            }
            else if (TimeF == TimeFormats.RTCFormat)
            {
                string[] strs = new string[6];
                if (ParamRTU.Length != 4)
                {
                    throw new Exception("Invalid data!");
                }

                strs[0] = ConvertFuncs.FromBCD((ushort)(ParamRTU[3] & 0x003F)).ToString("D2");
                strs[1] = ConvertFuncs.FromBCD((ushort)((ParamRTU[2] & 0xFF00) >> 8)).ToString("D2");
                strs[2] = ConvertFuncs.FromBCD((ushort)(ParamRTU[2] & 0x00FF)).ToString("D2");
                strs[3] = ConvertFuncs.FromBCD((ushort)(ParamRTU[0] & 0x003F)).ToString("D2");
                strs[4] = ConvertFuncs.FromBCD((ushort)((ParamRTU[0] & 0x1F00) >> 8)).ToString("D2");
                strs[5] = "20" + ConvertFuncs.FromBCD((ushort)(ParamRTU[1] & 0x00FF)).ToString("D2");

                return(strs);
            }
            return(null);
        }
Exemplo n.º 3
0
 public UserSettings(int id, int id_user, short msgs_per_page, bool white_listing, bool x_spam, DateTime last_login, int logins_count, string def_skin, string def_lang, Encoding def_charset_inc, Encoding def_charset_out, short def_timezone, string def_date_fmt, bool hide_folders, long mailbox_limit, bool allow_change_settings, bool allow_dhtml_editor, bool allow_direct_mode, Encoding db_charset, TimeFormats time_fmt)
 {
     _id                    = id;
     _id_user               = id_user;
     _msgs_per_page         = msgs_per_page;
     _white_listing         = white_listing;
     _x_spam                = x_spam;
     _last_login            = last_login;
     _logins_count          = logins_count;
     _def_skin              = def_skin;
     _def_lang              = def_lang;
     _def_charset_inc       = def_charset_inc.CodePage;
     _def_charset_out       = def_charset_out.CodePage;
     _def_timezone          = def_timezone;
     _def_date_fmt          = def_date_fmt;
     _def_time_fmt          = time_fmt;
     _hide_folders          = hide_folders;
     _mailbox_limit         = mailbox_limit;
     _allow_change_settings = allow_change_settings;
     _allow_dhtml_editor    = allow_dhtml_editor;
     _allow_direct_mode     = allow_direct_mode;
     _db_charset            = db_charset.CodePage;
     if (_def_lang == "Hebrew" || _def_lang == "Arabic")
     {
         _rtl = true;
     }
     else
     {
         _rtl = false;
     }
 }
Exemplo n.º 4
0
        public ClockViewModel()
        {
            //setup the preferences of the user.
            var dateFormat = ClockConfiguration.GetPreference(ClockConfiguration.Preferences.DateFormat);

            if (dateFormat == null)
            {
                dateFormat = DateFormats.First().Value;
                ClockConfiguration.SetPreference(ClockConfiguration.Preferences.DateFormat, dateFormat);
            }
            SelectedDateFormat = dateFormat;

            var timeFormat = ClockConfiguration.GetPreference(ClockConfiguration.Preferences.TimeFormat);

            if (timeFormat == null)
            {
                timeFormat = TimeFormats.First().Value;
                ClockConfiguration.SetPreference(ClockConfiguration.Preferences.TimeFormat, timeFormat);
            }

            SelectedTimeFormat = timeFormat;

            _timer          = new DispatcherTimer();
            _timer.Interval = new TimeSpan(0, 0, 1);
            _timer.Tick    += timer_Tick;
            _timer.Start();
        }
Exemplo n.º 5
0
        /// <summary><![CDATA[
        /// Format a time of day for output.
        /// ]]></summary>
        /// <param name="date">Time variable to format.</param>
        /// <param name="format">Time format.</param>
        /// <returns>String with the time of day formatted as requested.</returns>
        public static string TimeFormat(this DateTime date, TimeFormats format)
        {
            string result = string.Empty;

            try
            {
                switch (format)
                {
                case TimeFormats.Standard:
                    result = date.ToString("h:mmtt");
                    break;

                case TimeFormats.SqlMilitary:
                    result = date.ToString("HH:mm:ss");
                    break;

                case TimeFormats.Military:
                    result = date.ToString("HH:mm");
                    break;

                default:
                    result = date.ToString("h:mmtt");
                    break;
                }
            }
            catch
            { }

            return(result);
        }
        public TimeConfig(XElement TimeXElement)
        {
            try
            {
                timeFormat = StringToTimeFormat(TimeXElement.Attribute("TimeFormat").Value);
            }
            catch
            {
                throw new Exception("Error time format!");
            }


            if (timeFormat == TimeFormats.STMFormat)
            {
                try
                {
                    STMProcAddr1 = ConvertFuncs.UInt16ToWord(TimeXElement.Attribute("STMProcAddr1").Value);
                    STMProcAddr2 = ConvertFuncs.UInt16ToWord(TimeXElement.Attribute("STMProcAddr2").Value);
                    STMProcAddr3 = ConvertFuncs.UInt16ToWord(TimeXElement.Attribute("STMProcAddr3").Value);
                    STMProcAddr4 = ConvertFuncs.UInt16ToWord(TimeXElement.Attribute("STMProcAddr4").Value);

                    STMProcAddr1_1 = ConvertFuncs.UInt16ToWord(TimeXElement.Attribute("STMProcAddr1_1").Value);
                    STMProcAddr2_1 = ConvertFuncs.UInt16ToWord(TimeXElement.Attribute("STMProcAddr2_1").Value);
                    STMProcAddr3_1 = ConvertFuncs.UInt16ToWord(TimeXElement.Attribute("STMProcAddr3_1").Value);
                    STMProcAddr4_1 = ConvertFuncs.UInt16ToWord(TimeXElement.Attribute("STMProcAddr4_1").Value);
                }
                catch
                {
                    throw new Exception("Error time format!");
                }
            }
            else if (timeFormat == TimeFormats.ADSPFormat)
            {
                try
                {
                    ReadAddr    = ConvertFuncs.UInt16ToWord(TimeXElement.Attribute("ReadAddr").Value);
                    SetAddr     = ConvertFuncs.UInt16ToWord(TimeXElement.Attribute("SetAddr").Value);
                    AddrSetTime = ConvertFuncs.UInt16ToWord(TimeXElement.Attribute("AddrSetTime").Value);
                }
                catch
                {
                    throw new Exception("Error time format!");
                }
            }
            else if (timeFormat == TimeFormats.RTCFormat)
            {
                try
                {
                    ReadAddr = ConvertFuncs.UInt16ToWord(TimeXElement.Attribute("ReadAddr").Value);
                    SetAddr  = ConvertFuncs.UInt16ToWord(TimeXElement.Attribute("SetAddr").Value);
                }
                catch
                {
                    throw new Exception("Error time format!");
                }
            }
        }
Exemplo n.º 7
0
        public UserSettings(string dataFolder)
        {
            WebmailSettings settings;

            if (dataFolder != string.Empty)
            {
                settings = (new WebMailSettingsCreator()).CreateWebMailSettings(dataFolder);
            }
            else
            {
                settings = (new WebMailSettingsCreator()).CreateWebMailSettings();
            }

            _id            = -1;
            _id_user       = -1;
            _msgs_per_page = settings.MailsPerPage;
            _white_listing = false;
            _x_spam        = false;
            _last_login    = DateTime.Now;
            _logins_count  = 1;
            _def_skin      = settings.DefaultSkin;
            _def_lang      = settings.DefaultLanguage;
            try
            {
                _def_charset_inc = settings.DefaultUserCharset;
                _def_charset_out = settings.DefaultUserCharset;
            }
            catch (Exception)
            {
                _def_charset_inc = Encoding.Default.CodePage;
                _def_charset_out = Encoding.UTF8.CodePage;
            }
            _def_timezone          = settings.DefaultTimeZone;
            _def_date_fmt          = Constants.DateFormats.MMDDYY;
            _def_time_fmt          = TimeFormats.F12;
            _hide_folders          = false;
            _mailbox_limit         = settings.MailboxSizeLimit;
            _allow_change_settings = settings.AllowUsersChangeEmailSettings;
            _allow_dhtml_editor    = settings.AllowDhtmlEditor;
            _allow_direct_mode     = settings.AllowDirectMode;
            _db_charset            = Encoding.UTF8.CodePage;
            _horiz_resizer         = 150;
            _vert_resizer          = 115;
            _mark                    = 0;
            _reply                   = 0;
            _contacts_per_page       = 20;
            _view_mode               = ViewMode.WithPreviewPane;
            _auto_checkmail_interval = 0;
            if (_def_lang == "Hebrew" || _def_lang == "Arabic")
            {
                _rtl = true;
            }
            else
            {
                _rtl = false;
            }
        }
Exemplo n.º 8
0
        public static string ConvertTimeToString(TimeSpan time, TimeFormats format)
        {
            string timeAsString = "";

            if (format == TimeFormats.HH_MM_AM)
            {
                timeAsString = DateTime.Today.Add(time).ToString("hh:mm tt", System.Globalization.CultureInfo.InvariantCulture);
            }
            return(timeAsString);
        }
Exemplo n.º 9
0
        public static TimeSpan ConvertStringToTime(string timeAsString, TimeFormats format)
        {
            TimeSpan time = TimeSpan.MinValue;

            timeAsString = FixFuckingTime(timeAsString);
            if (format == TimeFormats.HH_MM_AM)
            {
                time = DateTime.ParseExact(timeAsString, "hh:mm tt", System.Globalization.CultureInfo.InvariantCulture).TimeOfDay;
            }
            return(time);
        }
Exemplo n.º 10
0
        //public PrayerTimeDto GetPrayerTimes(DateTime date, double lat, double lng, double elev, double timezone, bool isDst = false, TimeFormats format = TimeFormats.Hour12)
        public PrayerTimeDto GetPrayerTimes(DateTime date, double lat, double lng, double elev, double timezone, bool isDst, TimeFormats format)
        {
            _latitude = lat;
            _longitude = lng;
            _elevation = elev;
            _timezone = timezone + (isDst ? 1 : 0);
            _timeFormat = format;
            _julianDate = ConvertToJulian(date) - _longitude / (15 * 24);

            return ComputeTimes();
        }
        public static string ExtractTimeFromArray(ushort[] ParamRTU, TimeFormats TimeF, int Index = 0)
        {
            if (TimeF == TimeFormats.STMFormat)
            {
                if (ParamRTU.Length - Index < 4)
                {
                    throw new Exception("Invalid data!");
                }

                string str = "";
                str = str + (ParamRTU[3 + Index] & 0x00FF).ToString("X2") + ":";
                str = str + ((ParamRTU[2 + Index] >> 8) & 0x00FF).ToString("X2") + ":" + (ParamRTU[2 + Index] & 0x00FF).ToString("X2") + " ";

                str = str + (ParamRTU[0 + Index] & 0x003F).ToString("X2") + "/" + ((ParamRTU[0 + Index] >> 8) & 0x001F).ToString("X2") + "/";
                str = str + "20" + (ParamRTU[1 + Index] & 0x00FF).ToString("X2");
                return(str);
            }
            else if (TimeF == TimeFormats.ADSPFormat)
            {
                if (ParamRTU.Length - Index < 7)
                {
                    throw new Exception("Invalid data!");
                }

                string str = "";

                str = (ParamRTU[4 + Index] & 0x00FF).ToString("X2") + "/" + (ParamRTU[5 + Index] & 0x001F).ToString("X2") + "/" +
                      "20" + (ParamRTU[6 + Index] & 0x00FF).ToString("X2") + " " +
                      (ParamRTU[2 + Index] & 0x00FF).ToString("X2") + ":" +
                      (ParamRTU[1 + Index] & 0x00FF).ToString("X2") + ":" + (ParamRTU[0 + Index] & 0x00FF).ToString("X2") /* + "." + (ParamRTU[3]).ToString("D3")*/;


                return(str);
            }
            else if (TimeF == TimeFormats.RTCFormat)
            {
                if (ParamRTU.Length - Index < 4)
                {
                    throw new Exception("Invalid data!");
                }

                string str = "";

                str = ConvertFuncs.FromBCD((ushort)(ParamRTU[0 + Index] & 0x003F)).ToString("D2") + " / " + ConvertFuncs.FromBCD((ushort)((ParamRTU[0 + Index] & 0x1F00) >> 8)).ToString("D2") + " / " +
                      "20" + ConvertFuncs.FromBCD((ushort)(ParamRTU[1 + Index] & 0x00FF)).ToString("D2") + "   " +
                      ConvertFuncs.FromBCD((ushort)(ParamRTU[3 + Index] & 0x003F)).ToString("D2") + ":" +
                      ConvertFuncs.FromBCD((ushort)((ParamRTU[2 + Index] & 0xFF00) >> 8)).ToString("D2") + ":" + ConvertFuncs.FromBCD((ushort)(ParamRTU[2 + Index] & 0x00FF)).ToString("D2") +
                      "." + (ParamRTU[3 + Index] >> 6).ToString("D3");


                return(str);
            }
            return("");
        }
Exemplo n.º 12
0
        public PrayerTimeDto GetFormattedTimes(TimeFormats format)
        {
            var ptime = new PrayerTimeDto();

            ptime.Fajr = FormatTime(Fajr, format);
            ptime.Dhuhur = FormatTime(Dhuhur, format);
            ptime.Asr = FormatTime(Asr, format);
            ptime.Magrib = FormatTime(Magrib, format);
            ptime.Isha = FormatTime(Isha, format);

            return ptime;
        }
Exemplo n.º 13
0
 public TimeFormat(TimeFormats key, string title, string value)
 {
     if (key == TimeFormats.None)
       {
     throw new ArgumentNullException("key");
       }
       if (string.IsNullOrEmpty(title))
       {
     throw new ArgumentNullException("title");
       }
       _key = key;
       _title = title;
       _value = value;
 }
Exemplo n.º 14
0
 public TimeFormat(TimeFormats key, string title, string value)
 {
     if (key == TimeFormats.None)
     {
         throw new ArgumentNullException("key");
     }
     if (string.IsNullOrEmpty(title))
     {
         throw new ArgumentNullException("title");
     }
     _key   = key;
     _title = title;
     _value = value;
 }
Exemplo n.º 15
0
        public static Date Parse(string s)
        {
            Date d = new Date();

            d.divider       = s[0];
            d.timeDirection = (TimeDirection)int.Parse(s[1].ToString());
            int splitPoint = System.Text.RegularExpressions.Regex.Split(s.Substring(2), "[0-9]")[0].Length;

            d.displayStyle = TimeFormats.MatchDirection(s.Substring(2, splitPoint));
            string timeString = s.Substring(d.displayStyle.Length + 2);

            d.SetTime(timeString);

            return(d);
        }
Exemplo n.º 16
0
        static PhpValue GetSunTime(Context ctx, int timestamp, TimeFormats format, double latitude, double longitude, double zenith, double offset, bool getSunrise)
        {
            var zone  = PhpTimeZone.GetCurrentTimeZone(ctx);
            var utc   = DateTimeUtils.UnixTimeStampToUtc(timestamp);
            var local = TimeZoneInfo.ConvertTime(utc, zone);

            if (Double.IsNaN(latitude) || Double.IsNaN(longitude) || Double.IsNaN(zenith))
            {
                //LibraryConfiguration config = LibraryConfiguration.GetLocal(ScriptContext.CurrentContext);

                //if (Double.IsNaN(latitude))
                //    latitude = config.Date.Latitude;
                //if (Double.IsNaN(longitude))
                //    longitude = config.Date.Longitude;
                //if (Double.IsNaN(zenith))
                //    zenith = (getSunrise) ? config.Date.SunriseZenith : config.Date.SunsetZenith;
                throw new NotImplementedException();
            }

            if (Double.IsNaN(offset))
            {
                offset = zone.GetUtcOffset(local).TotalHours;
            }

            double result_utc = CalculateSunTime(local.DayOfYear, latitude, longitude, zenith, getSunrise);
            double result     = result_utc + offset;

            switch (format)
            {
            case TimeFormats.Integer:
                return(PhpValue.Create((timestamp - (timestamp % (24 * 3600))) + (int)(3600 * result)));

            case TimeFormats.String:
                return(PhpValue.Create(string.Format("{0:00}:{1:00}", (int)result, (int)(60 * (result - (double)(int)result)))));

            case TimeFormats.Double:
                return(PhpValue.Create(result));

            default:
                //PhpException.InvalidArgument("format");
                //return PhpValue.Null;
                throw new ArgumentException();
            }
        }
Exemplo n.º 17
0
        private void UpdateText()
        {
            TimeFormats formatKey = Format.Key;

            switch (Format.Key)
            {
            case TimeFormats.Constant:
            case TimeFormats.GeneralLong:
            case TimeFormats.GeneralShort:
                Text = Value.ToString(Format.Value);
                break;

            case TimeFormats.Custom:
                Text = Value.ToString(@CustomPattern);
                break;

            default:
                throw new NotImplementedException(string.Format("Format Key: {0}", formatKey));
            }
        }
Exemplo n.º 18
0
        private void InitSettings(AsrJuristics a, HighLatitudeMethods h)
        {
            _settings = new Setting
                            {
                                Imsak = Defaults.IMSAK_MINUTE,
                                IsImsakInMinutes = true,
                                DhuhurInMinutes = Defaults.DHUHUR_MINUTE,
                                AsrJuristic = a,
                                HighLatitudeMethod = h
                            };

            // from calc param
            _settings.Fajr = _calcMethod.Params.Fajr;

            _settings.Magrib = _calcMethod.Params.Magrib;
            _settings.IsMagribInMinutes = _calcMethod.Params.IsMagribInMinutes;

            _settings.Isha = _calcMethod.Params.Isha;
            _settings.IsIshaInMinutes = _calcMethod.Params.IsIshaInMinutes;

            _settings.Midnight = _calcMethod.Params.Midnight;

            _timeFormat = Defaults.TIME_FORMAT;
        }
Exemplo n.º 19
0
 public static PhpValue date_sunset(Context ctx, int timestamp, TimeFormats format, double latitude, double longitude)
 {
     return(GetSunTime(ctx, timestamp, format, latitude, longitude, Double.NaN, Double.NaN, false));
 }
Exemplo n.º 20
0
 public static PhpValue date_sunrise(Context ctx, int timestamp, TimeFormats format, double latitude, double longitude, double zenith)
 {
     return(GetSunTime(ctx, timestamp, format, latitude, longitude, zenith, Double.NaN, true));
 }
Exemplo n.º 21
0
 /// <summary><![CDATA[
 /// Format a time of day for output.
 /// ]]></summary>
 /// <param name="date">Time variable to format.</param>
 /// <param name="format">Time format.</param>
 /// <returns>String with the time of day formatted as requested.</returns>
 public static string TimeFormat(this string date, TimeFormats format)
 {
     return(TimeFormat(Convert.ToDateTime(date), format));
 }
Exemplo n.º 22
0
        private static string FormatTime(double time, TimeFormats format)
        {
            if (double.IsNaN(time)) return Defaults.INVALID_TIME;

            if (format == TimeFormats.Float) return time.ToString();

            time = MathUtils.FixHour(time + 0.5/60); // add 0.5 minutes to round
            var hours = Math.Floor(time);
            var minutes = Math.Floor((time - hours)*60);

            bool showAmPm = format == TimeFormats.Hour12;
            string amPm = string.Empty;
            if (showAmPm)
                amPm = hours < 12 ? "am" : "pm";

            if (format == TimeFormats.Hour12)
                hours = ((hours + 12 - 1)%12 + 1);

            var intHours = Convert.ToInt32(hours);
            var intMinutes = Convert.ToInt32(minutes);

            var timeStr = string.Format("{0:D2}:{1:D2} {2}",
                                        intHours,
                                        intMinutes,
                                        amPm);
            return timeStr;
        }
Exemplo n.º 23
0
        public PrayerTimeDto GetFormattedTimes(TimeFormats format)
        {
            var ptime = new PrayerTimeDto();

            ptime.Imsak = FormatTime(Imsak, format);
            ptime.Fajr = FormatTime(Fajr, format);
            ptime.Sunrise = FormatTime(Sunrise, format);
            ptime.Dhuhur = FormatTime(Dhuhur, format);
            ptime.Asr = FormatTime(Asr, format);
            ptime.Sunset = FormatTime(Sunset, format);
            ptime.Magrib = FormatTime(Magrib, format);
            ptime.Isha = FormatTime(Isha, format);
            ptime.Midnight = FormatTime(Midnight, format);

            return ptime;
        }
Exemplo n.º 24
0
 public static PhpValue date_sunrise(Context ctx, int timestamp, TimeFormats format)
 {
     return(GetSunTime(ctx, timestamp, format, Double.NaN, Double.NaN, Double.NaN, Double.NaN, true));
 }
Exemplo n.º 25
0
        /// <summary>
        /// Format a time of day for output.
        /// </summary>
        /// <example>
        /// <code>
        /// using Mezzocode.Halide3;
        /// ...
        /// string result = h3Temporal.TimeFormat(
        ///		theTime,
        ///		h3Temporal.TimeFormats.standard);
        /// </code>
        /// </example>
        /// <param name="date">Time variable to format.</param>
        /// <param name="format">Time format.</param>
        /// <returns>String with the time of day formatted as requested.</returns>
        public static String TimeFormat(System.DateTime date, TimeFormats format)
        {
            string thedate = string.Empty;

            try
            {
                switch (format)
                {
                    case TimeFormats.standard:
                        thedate = date.ToString("h:mmtt");
                        break;
                    case TimeFormats.SQLmilitary:
                        thedate = date.ToString("HH:mm:ss");
                        break;
                    case TimeFormats.military:
                        thedate = date.ToString("HH:mm");
                        break;
                    default:
                        thedate = date.ToString("h:mmtt");
                        break;
                }
            }
            catch
            { }
            return (thedate);
        }
Exemplo n.º 26
0
        static PhpValue GetSunTime(Context ctx, int timestamp, TimeFormats format, double latitude, double longitude, double zenith, double offset, bool getSunrise)
        {
            var zone = PhpTimeZone.GetCurrentTimeZone(ctx);
            var utc = DateTimeUtils.UnixTimeStampToUtc(timestamp);
            var local = TimeZoneInfo.ConvertTime(utc, zone);

            if (Double.IsNaN(latitude) || Double.IsNaN(longitude) || Double.IsNaN(zenith))
            {
                //LibraryConfiguration config = LibraryConfiguration.GetLocal(ScriptContext.CurrentContext);

                //if (Double.IsNaN(latitude))
                //    latitude = config.Date.Latitude;
                //if (Double.IsNaN(longitude))
                //    longitude = config.Date.Longitude;
                //if (Double.IsNaN(zenith))
                //    zenith = (getSunrise) ? config.Date.SunriseZenith : config.Date.SunsetZenith;
                throw new NotImplementedException();
            }

            if (Double.IsNaN(offset))
                offset = zone.GetUtcOffset(local).TotalHours;

            double result_utc = CalculateSunTime(local.DayOfYear, latitude, longitude, zenith, getSunrise);
            double result = result_utc + offset;

            switch (format)
            {
                case TimeFormats.Integer:
                    return PhpValue.Create((timestamp - (timestamp % (24 * 3600))) + (int)(3600 * result));

                case TimeFormats.String:
                    return PhpValue.Create(string.Format("{0:00}:{1:00}", (int)result, (int)(60 * (result - (double)(int)result))));

                case TimeFormats.Double:
                    return PhpValue.Create(result);

                default:
                    //PhpException.InvalidArgument("format");
                    //return PhpValue.Null;
                    throw new ArgumentException();
            }
        }
Exemplo n.º 27
0
 public static PhpValue date_sunset(Context ctx, int timestamp, TimeFormats format, double latitude, double longitude, double zenith, double offset)
 {
     return GetSunTime(ctx, timestamp, format, latitude, longitude, zenith, offset, false);
 }
Exemplo n.º 28
0
 // set the time format
 public void SetTimeFormat(TimeFormats timeFormat)
 {
     _timeFormat = timeFormat;
 }
Exemplo n.º 29
0
		[ImplementsFunction("date_sunset")]
        public static object GetSunsetTime(long timestamp, TimeFormats format, double latitude, double longitude, double zenith, double offset)
		{
			return GetSunTime(timestamp, format, latitude, longitude, zenith, offset, false);
Exemplo n.º 30
0
		[ImplementsFunction("date_sunset")]
        public static object GetSunsetTime(long timestamp, TimeFormats format)
		{
			return GetSunTime(timestamp, format, Double.NaN, Double.NaN, Double.NaN, Double.NaN, false);
Exemplo n.º 31
0
		[ImplementsFunction("date_sunrise")]
		public static object GetSunriseTime(long timestamp, TimeFormats format)
		{
			return GetSunTime(timestamp, format, Double.NaN, Double.NaN, Double.NaN, Double.NaN, true);
Exemplo n.º 32
0
 public static PhpValue date_sunset(Context ctx, int timestamp, TimeFormats format, double latitude, double longitude, double zenith, double offset)
 {
     return(GetSunTime(ctx, timestamp, format, latitude, longitude, zenith, offset, false));
 }
Exemplo n.º 33
0
		[ImplementsFunction("date_sunrise")]
		public static object GetSunriseTime(int timestamp, TimeFormats format, double latitude)
		{
			return GetSunTime(timestamp, format, latitude, Double.NaN, Double.NaN, Double.NaN, true);
Exemplo n.º 34
0
 /// <summary>
 /// Format a time of day for output.
 /// </summary>
 /// <example>
 /// <code>
 /// using Mezzocode.Halide3;
 /// ...
 /// string result = h3Temporal.TimeFormat(
 ///		theTime,
 ///		h3Temporal.TimeFormats.standard);
 /// </code>
 /// </example>
 /// <param name="date">Time variable to format.</param>
 /// <param name="format">Time format.</param>
 /// <returns>String with the time of day formatted as requested.</returns>
 public static String TimeFormat(string date, TimeFormats format)
 {
     return TimeFormat(Convert.ToDateTime(date), format);
 }
Exemplo n.º 35
0
		[ImplementsFunction("date_sunrise")]
		public static object GetSunriseTime(int timestamp, TimeFormats format, double latitude, double longitude, double zenith, double offset)
		{
			return GetSunTime(timestamp, format, latitude, longitude, zenith, offset, true);
Exemplo n.º 36
0
 public static PhpValue date_sunrise(Context ctx, int timestamp, TimeFormats format, double latitude, double longitude, double zenith)
 {
     return GetSunTime(ctx, timestamp, format, latitude, longitude, zenith, Double.NaN, true);
 }
Exemplo n.º 37
0
		[ImplementsFunction("date_sunrise")]
        public static object GetSunriseTime(long timestamp, TimeFormats format, double latitude, double longitude, double zenith)
		{
			return GetSunTime(timestamp, format, latitude, longitude, zenith, Double.NaN, true);
Exemplo n.º 38
0
 public static PhpValue date_sunset(Context ctx, int timestamp, TimeFormats format)
 {
     return GetSunTime(ctx, timestamp, format, Double.NaN, Double.NaN, Double.NaN, Double.NaN, false);
 }
Exemplo n.º 39
0
		[ImplementsFunction("date_sunset")]
        public static object GetSunsetTime(long timestamp, TimeFormats format, double latitude, double longitude)
		{
			return GetSunTime(timestamp, format, latitude, longitude, Double.NaN, Double.NaN, false);
Exemplo n.º 40
0
 public static PhpValue date_sunset(Context ctx, int timestamp, TimeFormats format, double latitude, double longitude)
 {
     return GetSunTime(ctx, timestamp, format, latitude, longitude, Double.NaN, Double.NaN, false);
 }
Exemplo n.º 41
0
        public static object GetSunTime(long timestamp, TimeFormats format, double latitude, double longitude, double zenith, double offset, bool getSunrise)
		{
			var zone = PhpTimeZone.CurrentTimeZone;
			DateTime utc = DateTimeUtils.UnixTimeStampToUtc(timestamp);
            DateTime local = TimeZoneInfo.ConvertTimeFromUtc(utc, zone);

			if (Double.IsNaN(latitude) || Double.IsNaN(longitude) || Double.IsNaN(zenith))
			{
				LibraryConfiguration config = LibraryConfiguration.GetLocal(ScriptContext.CurrentContext);

				if (Double.IsNaN(latitude))
					latitude = config.Date.Latitude;
				if (Double.IsNaN(longitude))
					longitude = config.Date.Longitude;
				if (Double.IsNaN(zenith))
					zenith = (getSunrise) ? config.Date.SunriseZenith : config.Date.SunsetZenith;
			}

			if (Double.IsNaN(offset))
				offset = zone.GetUtcOffset(local).TotalHours;

			double result_utc = CalculateSunTime(local.DayOfYear, latitude, longitude, zenith, getSunrise);
			double result = result_utc + offset;

			switch (format)
			{
				case TimeFormats.Integer:
					return (timestamp - (timestamp % (24 * 3600))) + (int)(3600 * result);

				case TimeFormats.String:
					return String.Format("{0:00}:{1:00}", (int)result, (int)(60 * (result - (double)(int)result)));

				case TimeFormats.Double:
					return result;

				default:
					PhpException.InvalidArgument("format");
					return null;
			}
Exemplo n.º 42
0
        private void loadSettings()
        {
            if (AppSettings.loadSettings("countryFullName") != null)
                App.countryFullName = Convert.ToString(AppSettings.loadSettings("countryFullName"));

            if (AppSettings.loadSettings("ln") != null)
                App.ln = Convert.ToDouble(AppSettings.loadSettings("ln"));

            if (AppSettings.loadSettings("lt") != null)
                App.lt = Convert.ToDouble(AppSettings.loadSettings("lt"));

            if (AppSettings.loadSettings("backgroundImage") != null)
                App.backgroundImage = Convert.ToString(AppSettings.loadSettings("backgroundImage"));

            if (AppSettings.loadSettings("fajrNotification") != null)
                App.fajrNotification = Convert.ToInt32(AppSettings.loadSettings("fajrNotification"));

            if (AppSettings.loadSettings("dhuhrNotification") != null)
                App.dhuhrNotification = Convert.ToInt16(AppSettings.loadSettings("dhuhrNotification"));

            if (AppSettings.loadSettings("asrNotification") != null)
                App.asrNotification = Convert.ToInt16(AppSettings.loadSettings("asrNotification"));

            if (AppSettings.loadSettings("maghribNotification") != null)
                App.maghribNotification = Convert.ToInt16(AppSettings.loadSettings("maghribNotification"));

            if (AppSettings.loadSettings("ishaNotification") != null)
                App.ishaNotification = Convert.ToInt16(AppSettings.loadSettings("ishaNotification"));

            if (AppSettings.loadSettings("fajrAdjustment") != null)
                App.fajrAdjustment = Convert.ToDouble(AppSettings.loadSettings("fajrAdjustment"));

            if (AppSettings.loadSettings("dhuhrAdjustment") != null)
                App.dhuhrAdjustment = Convert.ToDouble(AppSettings.loadSettings("dhuhrAdjustment"));

            if (AppSettings.loadSettings("asrAdjustment") != null)
                App.asrAdjustment = Convert.ToDouble(AppSettings.loadSettings("asrAdjustment"));

            if (AppSettings.loadSettings("maghribAdjustment") != null)
                App.maghribAdjustment = Convert.ToDouble(AppSettings.loadSettings("maghribAdjustment"));

            if (AppSettings.loadSettings("ishaAdjustment") != null)
                App.ishaAdjustment = Convert.ToDouble(AppSettings.loadSettings("ishaAdjustment"));

            if (AppSettings.loadSettings("isDST") != null)
                App.isDST = Convert.ToBoolean(Convert.ToInt16(AppSettings.loadSettings("isDST")));

            if (AppSettings.loadSettings("timeZone") != null)
                App.timeZone = Convert.ToInt32(Convert.ToInt16(AppSettings.loadSettings("timeZone")));

            if (AppSettings.loadSettings("timeZoneSelectedIndex") != null)
                App.timeZone = Convert.ToInt32(Convert.ToInt16(AppSettings.loadSettings("timeZoneSelectedIndex")));

            if (AppSettings.loadSettings("displayTimeFormat") != null)
                App.displayTimeFormat = (TimeFormats)Enum.Parse(typeof(TimeFormats), AppSettings.loadSettings("displayTimeFormat"));

            if (AppSettings.loadSettings("cm") != null)
                App.cm = (CalculationMethods)Enum.Parse(typeof(CalculationMethods), AppSettings.loadSettings("cm"));

            if (AppSettings.loadSettings("hlm") != null)
                App.hlm = (HighLatitudeMethods)Enum.Parse(typeof(HighLatitudeMethods), AppSettings.loadSettings("hlm"));

            if (AppSettings.loadSettings("aj") != null)
                App.aj = (AsrJuristics)Enum.Parse(typeof(AsrJuristics), AppSettings.loadSettings("aj"));

            if (AppSettings.loadSettings("translationLanguage") != null)
                App.translationLanguage = AppSettings.loadSettings("translationLanguage");

            if (AppSettings.loadSettings("quranChapterNameLang") != null)
                App.quranChapterNameLang = Convert.ToInt16(AppSettings.loadSettings("quranChapterNameLang"));

            if (AppSettings.loadSettings("quranReadingBookmark") != null)
                App.quranReadingBookmark = AppSettings.loadSettings("quranReadingBookmark");

            if (AppSettings.loadSettings("scheduleFactorySetupDate") == null)
                App.scheduleFactorySetupDate = new DateTime().Date.AddYears(-1);
            else
                App.scheduleFactorySetupDate = Convert.ToDateTime(AppSettings.loadSettings("scheduleFactorySetupDate"));
        }