GetAbbreviatedMonthName() public méthode

Returns the culture-specific abbreviated name of the specified month based on the culture associated with the current DateTimeFormatInfo object.
public GetAbbreviatedMonthName ( int month ) : string
month int An integer from 1 through 13 representing the name of the month to retrieve.
Résultat string
        public static String DatetimeAMesCorto(DateTime fecha)
        {
            System.Globalization.DateTimeFormatInfo mfi = Thread.CurrentThread.CurrentUICulture.DateTimeFormat;
            string Mes = mfi.GetAbbreviatedMonthName(fecha.Month).Replace(".", "");

            return(Mes);
        }
        public static String IntAMes(int mes)
        {
            System.Globalization.DateTimeFormatInfo mfi = Thread.CurrentThread.CurrentUICulture.DateTimeFormat;
            string Mes = mfi.GetAbbreviatedMonthName(mes).Replace(".", "");

            return(Mes);
        }
Exemple #3
0
        public JObject Get(int year)
        {
            //DO DO: egt the month from the query string
            DateTimeFormatInfo dtfi = new DateTimeFormatInfo();

            JObject result = new JObject(
                new JProperty("bikes",
                    new JArray(Bike.getBikes().OrderBy(b => b.name).Select(b => JObject.FromObject(b)))),

                new JProperty("riders",
                    new JArray(Rider.getRiders().OrderBy(r => r.name).Select(r => JObject.FromObject(r)))),

                new JProperty("routes",
                    new JArray(Route.getRoutes().OrderBy(r => r.name).Select(r => JObject.FromObject(r)))),

                new JProperty("rides",
                    new JArray(Ride.getRides().OrderByDescending(r => r.ride_date).Select(r => JObject.FromObject(new RideVM(r))))),

                new JProperty("payments",
                    new JArray(Payment.getPayments().OrderBy(p => p.paid_date).Select(p => p.toJObject()))),

                new JProperty("colorList", getChartColors()),

                new JProperty("months", Enumerable.Range(1, 12).Select(i => new JObject(
                    new JProperty("month", i), new JProperty("caption", dtfi.GetAbbreviatedMonthName(i))))),

                new JProperty("riderSummary", getRiderSummary(year))

            );

            App.BikesDebug.dumpToFile("model.json", result.ToString(Newtonsoft.Json.Formatting.Indented));

            return result;
        }
        public static String DateTimeAFechaCortaConMesTextoAbreviado(DateTime fecha)
        {
            System.Globalization.DateTimeFormatInfo mfi = Thread.CurrentThread.CurrentUICulture.DateTimeFormat;
            string strMonthName = mfi.GetAbbreviatedMonthName(fecha.Month).Replace(".", "");

            String fechaSt = fecha.Day.ToString("00") + @"-" + strMonthName.ToUpper() + @"-" + fecha.Year;

            return(fechaSt);
        }
        public static String DateTimeAFechaCortaConDiaMesTexto(DateTime fecha)
        {
            System.Globalization.DateTimeFormatInfo mfi = Thread.CurrentThread.CurrentUICulture.DateTimeFormat;
            string DiaSemana = mfi.GetDayName(fecha.DayOfWeek);
            string Mes       = mfi.GetAbbreviatedMonthName(fecha.Month).Replace(".", "");

            String fechaSt = DiaSemana.Substring(0, 3) + "," + IntANDigitos(fecha.Day, 2) + @"" + Mes + @"'" + fecha.Year.ToString().Substring(2, 2);

            return(fechaSt);
        }
        /// <summary>
        /// Get lines chart information
        /// </summary>
        /// <returns></returns>
        public static List<Dictionary<string, object>> GetSuperAdminLineChart()
        {
            SqlConnection sql = new SqlConnection(ConfigurationManager.ConnectionStrings["DB"].ConnectionString);
            SqlCommand cmd = new SqlCommand(@"SELECT StatDate, UserCount FROM Stats_UserCount WHERE StatDate >= DATEADD(year, -1, GetDate()) ORDER BY StatDate ASC;
                                              SELECT StatDate, UserCount FROM Stats_ExchCount WHERE StatDate >= DATEADD(year, -1, GetDate()) ORDER BY StatDate ASC;
                                              SELECT StatDate, UserCount FROM Stats_CitrixCount WHERE StatDate >= DATEADD(year, -1, GetDate()) ORDER BY StatDate ASC;", sql);

            try
            {
                // Open connection to database
                sql.Open();

                // Keep track months to years
                Dictionary<string, object> userMonthYearValue = new Dictionary<string, object>();
                Dictionary<string, object> exchMonthYearValue = new Dictionary<string, object>();
                Dictionary<string, object> citrixMonthYearValue = new Dictionary<string, object>();

                // Formatter for months
                DateTimeFormatInfo mfi = new DateTimeFormatInfo();

                SqlDataReader r = cmd.ExecuteReader();
                if (r.HasRows)
                {
                    while (r.Read())
                    {
                        DateTime statDate = DateTime.Parse(r["StatDate"].ToString());
                        int value = int.Parse(r["UserCount"].ToString());

                        string keyValue = mfi.GetAbbreviatedMonthName(statDate.Month) + " " + statDate.Year;

                        if (!userMonthYearValue.ContainsKey(keyValue))
                        {
                            // Add to our dictionary
                            userMonthYearValue.Add(keyValue, r["UserCount"]);
                        }
                        else
                        {
                            // Update our dictionary (because we want the last value in the month)
                            userMonthYearValue[keyValue] = r["UserCount"];
                        }
                    }

                    // Next result set
                    r.NextResult();

                    if (r.HasRows)
                    {
                        while (r.Read())
                        {
                            DateTime statDate = DateTime.Parse(r["StatDate"].ToString());
                            int value = int.Parse(r["UserCount"].ToString());

                            string keyValue = mfi.GetAbbreviatedMonthName(statDate.Month) + " " + statDate.Year;

                            if (!exchMonthYearValue.ContainsKey(keyValue))
                            {
                                // Add to our dictionary
                                exchMonthYearValue.Add(keyValue, r["UserCount"]);
                            }
                            else
                            {
                                // Update our dictionary (because we want the last value in the month)
                                exchMonthYearValue[keyValue] = r["UserCount"];
                            }
                        }
                    }

                    // Last result set
                    r.NextResult();

                    if (r.HasRows)
                    {
                        while (r.Read())
                        {
                            DateTime statDate = DateTime.Parse(r["StatDate"].ToString());
                            int value = int.Parse(r["UserCount"].ToString());

                            string keyValue = mfi.GetAbbreviatedMonthName(statDate.Month) + " " + statDate.Year;

                            if (!citrixMonthYearValue.ContainsKey(keyValue))
                            {
                                // Add to our dictionary
                                citrixMonthYearValue.Add(keyValue, r["UserCount"]);
                            }
                            else
                            {
                                // Update our dictionary (because we want the last value in the month)
                                citrixMonthYearValue[keyValue] = r["UserCount"];
                            }
                        }
                    }
                }


                // Close
                r.Close();
                sql.Close();

                // Dispose
                r.Dispose();

                // Return our custom object
                return new List<Dictionary<string, object>>() { userMonthYearValue, exchMonthYearValue, citrixMonthYearValue };
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                cmd.Dispose();
                sql.Dispose();
            }
        }
Exemple #7
0
    public void createtable(int month, int year)
    {
        System.Globalization.DateTimeFormatInfo forb = new System.Globalization.DateTimeFormatInfo();
        DataTable roomtab = getroomtable();

        int Year = DateTime.Now.Year;                                           //
        int Month = DateTime.Now.Month;                                         //Getting no of days in the month displayed so to create columns
        int today = Convert.ToInt16(DateTime.Today.ToString("dd"));
        int noofdays = System.DateTime.DaysInMonth(year, month);                //

        DataTable dt = new DataTable();                                         // temporary datatables for creating gridview   dt for maingridview
        DataTable dt1 = new DataTable();                                        // dt1 for Header

        int nofofroom1 = roomtab.Rows.Count;                                    //

        dt.Columns.Add("RoomNo  :");                                            //Adding first column Head
        dt1.Columns.Add("RoomNo  :");
        for (int i = 1; i <= noofdays; i++)
        {

            String mnth = ddlMonth.SelectedItem.Text;
            DateTime frmdate = Convert.ToDateTime(i.ToString()+"/" + mnth + "/" + year);
            var x = frmdate.ToString("MMM dd");
            string[] word = x.Split(' ');

            dt.Columns.Add(word[0] + "    " + word[1]);                          //Adding other column head
            dt1.Columns.Add(word[0] + "    " + word[1]);

        }

        int cntbed = 0;
        for (int j = 1; j <= nofofroom1; j++)                                     //Adding room nos. in first column
        {
            DataRow rw = dt.NewRow();
            rw["RoomNo  :"] = roomtab.Rows[j - 1].ItemArray[1] ;
            dt.Rows.Add(rw);
            cntbed++;
            if (Convert.ToInt16(roomtab.Rows[j - 1].ItemArray[3]) == 2)
            {
                DataRow rw1 = dt.NewRow();
                rw1["RoomNo  :"] = roomtab.Rows[j - 1].ItemArray[1] + ": 2nd ";
                dt.Rows.Add(rw1);
                cntbed++;

            }

            dt.AcceptChanges();
        }

        DataRow rw2 = dt1.NewRow();                                               //Adding a row into a grid view with header
           // rw2["RoomNo  :"] = "AluminiumnSQ";                                        // to adjust the width of header
        dt1.Rows.Add(rw2);
        dt1.AcceptChanges();
        GridView2.DataSource =dt1;                                                //
        GridView2.DataBind();                                                     //binding the data to griview with header

        GridView2.Rows[0].Style.Add("opacity", "0");                              // Hiding the row of the gridview with header

        GridView1.DataSource = dt;                                                //
        GridView1.DataBind();                                                     // Binding the main gridview with rooms nos.

        for (int i = 0; i <= noofdays; i++)                                       // Aligning header cells
        {
            GridView2.HeaderRow.Cells[i].Style.Add("text-align", "center");

        }

        for (int j = 0; j < cntbed; j++)
        {
            GridView1.Rows[j].Cells[0].Style.Add("background-color", "#22cc99");
            GridView1.Rows[j].Cells[0].Style.Add("border", "4px groove #fff");
            GridView1.Rows[j].Cells[0].Style.Add("text-align", "center");
            GridView1.Rows[j].Cells[0].Style.Add("width", "100px");
            GridView1.Rows[j].Style.Add("height", "50px");

            if (month == Month && year == Year)
            {
                GridView1.Rows[j].Cells[today].Style.Add("background-color", "#33FF99");        //for highlighting today
                GridView2.HeaderRow.Cells[today].Style.Add("background-color", "#33FF99");
                GridView2.HeaderRow.Cells[today].Style.Add("color", "black");
            }
        }

        if (!IsPostBack)
        {
            listpopulate(dt);                                                         //populate list in panel1  only for service provider access
        }
        getdata();                                                                // Getting the booking log in the main gridview
        if (month == 12)
        {
            forlab.InnerText = forb.GetAbbreviatedMonthName(1).ToString();
            backlab.InnerText = forb.GetAbbreviatedMonthName(month - 1).ToString();
        }
        else if (month == 1)
        {
            backlab.InnerText = forb.GetAbbreviatedMonthName(12).ToString();
            forlab.InnerText = forb.GetAbbreviatedMonthName(month + 1).ToString();
        }
        else
        {
            forlab.InnerText = forb.GetAbbreviatedMonthName(month + 1).ToString();
            backlab.InnerText = forb.GetAbbreviatedMonthName(month - 1).ToString();
        }
    }
        private void GetUserHistory(ref CPDatabase database, DateTime current, ref DateTimeFormatInfo mfi, ref Dictionary<string, object> statistics)
        {
            // Get first day of month
            DateTime firstDay = new DateTime(current.Year, current.Month, 1);
            DateTime lastDay = new DateTime(current.Year, current.Month, DateTime.DaysInMonth(current.Year, current.Month));

            var users = new int();
            if (current.Year == DateTime.Today.Year && current.Month == DateTime.Today.Month)
            {
                // If we are doing todays month then we just count the total amount of users
                users = (from u in database.Users
                         select u).Count();
            }
            else
            {
                // Otherwise we are on other months and we need to look at statistics
                users = (from u in database.Stats_UserCount
                             where u.StatDate >= firstDay
                             where u.StatDate <= lastDay
                             orderby u.StatDate ascending
                             select u.UserCount).FirstOrDefault();
            }

            if (users < 1)
            {
                // If this is the very first point and it was null then we need to set it to zero so it will populate the whole graph
                if (firstDay < DateTime.Now.AddMonths(-11))
                    statistics.Add(string.Format("{0} {1}", mfi.GetAbbreviatedMonthName(current.Month), current.Year), 0);
                else
                    statistics.Add(string.Format("{0} {1}", mfi.GetAbbreviatedMonthName(current.Month), current.Year), null);
            }
            else
                statistics.Add(string.Format("{0} {1}", mfi.GetAbbreviatedMonthName(current.Month), current.Year), users);
        }
Exemple #9
0
        /*=================================MatchAbbreviatedMonthName==================================
        **Action: Parse the abbreviated month name from string starting at str.Index.
        **Returns: A value from 1 to 12 for the first month to the twelveth month.
        **Arguments:    str: a __DTString.  The parsing will start from the
        **              next character after str.Index.
        **Exceptions: FormatException if an abbreviated month name can not be found.
        ==============================================================================*/

        private static bool MatchAbbreviatedMonthName(__DTString str, DateTimeFormatInfo dtfi, bool isThrowExp, ref int result) {
            int maxMatchStrLen = 0;
            result = -1;
            if (str.GetNext()) {
                //
                // Scan the month names (note that some calendars has 13 months) and find
                // the matching month name which has the max string length.
                // We need to do this because some cultures (e.g. "cs-CZ") which have
                // abbreviated month names with the same prefix.
                //            
                int monthsInYear = (dtfi.GetMonthName(13).Length == 0 ? 12: 13);
                for (int i = 1; i <= monthsInYear; i++) {
                    String searchStr = dtfi.GetAbbreviatedMonthName(i);
                    if (str.MatchSpecifiedWord(searchStr)) {
                        int matchStrLen = searchStr.Length;
                        if (matchStrLen > maxMatchStrLen) {
                            maxMatchStrLen = matchStrLen;
                            result = i;
                        }
                    }
                }
            }
            if (result > 0) {
                str.Index += (maxMatchStrLen - 1);
                return (true);
            }
            return (ParseFormatError(isThrowExp, "Format_BadDateTime"));            
        }
Exemple #10
0
        /*=================================MatchAbbreviatedMonthName==================================
        **Action: Parse the abbreviated month name from string starting at str.Index.
        **Returns: A value from 1 to 12 for the first month to the twelveth month.
        **Arguments:    str: a __DTString.  The parsing will start from the
        **              next character after str.Index.
        **Exceptions: FormatException if an abbreviated month name can not be found.
        ==============================================================================*/

        private static bool MatchAbbreviatedMonthName(ref __DTString str, DateTimeFormatInfo dtfi, ref int result) {
            int maxMatchStrLen = 0;
            result = -1;
            if (str.GetNext()) {
                //
                // Scan the month names (note that some calendars has 13 months) and find
                // the matching month name which has the max string length.
                // We need to do this because some cultures (e.g. "cs-CZ") which have
                // abbreviated month names with the same prefix.
                //
                int monthsInYear = (dtfi.GetMonthName(13).Length == 0 ? 12: 13);
                for (int i = 1; i <= monthsInYear; i++) {
                    String searchStr = dtfi.GetAbbreviatedMonthName(i);
                    int matchStrLen = searchStr.Length;
                    if ( dtfi.HasSpacesInMonthNames
                            ? str.MatchSpecifiedWords(searchStr, false, ref matchStrLen)
                            : str.MatchSpecifiedWord(searchStr)) {
                        if (matchStrLen > maxMatchStrLen) {
                            maxMatchStrLen = matchStrLen;
                            result = i;
                        }
                    }
                }

                // Search leap year form.
                if ((dtfi.FormatFlags & DateTimeFormatFlags.UseLeapYearMonth) != 0) {
                    int tempResult = str.MatchLongestWords(dtfi.internalGetLeapYearMonthNames(), ref maxMatchStrLen);
                    // We found a longer match in the leap year month name.  Use this as the result.
                    // The result from MatchLongestWords is 0 ~ length of word array.
                    // So we increment the result by one to become the month value.
                    if (tempResult >= 0) {
                        result = tempResult + 1;
                    }
                }


            }
            if (result > 0) {
                str.Index += (maxMatchStrLen - 1);
                return (true);
            }
            return false;
        }
Exemple #11
0
 private static String FormatMonth(int month, int repeatCount, DateTimeFormatInfo dtfi)
 {
     Contract.Assert(month >=1 && month <= 12, "month >=1 && month <= 12");
     if (repeatCount == 3)
     {
         return (dtfi.GetAbbreviatedMonthName(month));
     }
     // Call GetMonthName() here, instead of accessing MonthNames property, because we don't
     // want a clone of MonthNames, which will hurt perf.
     return (dtfi.GetMonthName(month));
 }
Exemple #12
0
        /// <summary>
        /// Gets the abbreviated or full month name for the specified <paramref name="month"/> and <paramref name="year"/> value, using the
        /// <paramref name="nameProvider"/> if not null or the <see cref="DateTimeFormatInfo"/> specified by <paramref name="info"/>.
        /// </summary>
        /// <param name="month">
        /// The month value to get the month name for.
        /// </param>
        /// <param name="year">
        /// The year value to get the month name for.
        /// </param>
        /// <param name="info">
        /// The <see cref="DateTimeFormatInfo"/> value to use.
        /// </param>
        /// <param name="nameProvider">
        /// The <see cref="ICustomFormatProvider"/> to get the name. This parameter has precedence before the
        /// <paramref name="info"/>. Can be <c>null</c>.
        /// </param>
        /// <param name="abbreviated">
        /// true to get the abbreviated month name; false otherwise.
        /// </param>
        /// <returns>
        /// The full or abbreviated month name specified by <paramref name="month"/> and <paramref name="year"/>.
        /// </returns>
        private static string GetMonthName(int month, int year, DateTimeFormatInfo info, ICustomFormatProvider nameProvider, bool abbreviated)
        {
            if (nameProvider != null)
            {
                return abbreviated ? nameProvider.GetAbbreviatedMonthName(year, month) : nameProvider.GetMonthName(year, month);
            }

            return abbreviated ? info.GetAbbreviatedMonthName(month) : info.GetMonthName(month);
        }
 // ----------------------------------------------------------------------
 public void ShowMonthNameInfo( DateTimeFormatInfo info, int month )
 {
     Console.WriteLine( "Current month name: " + info.GetMonthName( month ) );
     Console.WriteLine( "Current abbreviated month name: " + info.GetAbbreviatedMonthName( month ) );
     Console.WriteLine( "Current month index: " + info.MonthNames, info.GetMonthName( month ) );
 }
Exemple #14
0
        //
        // Check the word at the current index to see if it matches a month name.
        // Return -1 if a match is not found. Otherwise, a value from 1 to 12 is returned.
        //
        private static int GetMonthNumber(__DTString str, DateTimeFormatInfo dtfi)
        {
            //
            // Check the month name specified in dtfi.
            //
            int i;

            int monthInYear = (dtfi.GetMonthName(13).Length == 0 ? 12 : 13);
            int maxLen = 0;
            int result = -1;
            int index;
            String word = str.PeekCurrentWord();

            //
            // We have to match the month name with the longest length, 
            // since there are cultures which have more than one month names
            // with the same prefix.
            //
            for (i = 1; i <= monthInYear; i++) {
                String monthName = dtfi.GetMonthName(i);

                if ((index = str.CompareInfo.IndexOf(
                    word, monthName, CompareOptions.IgnoreCase)) >= 0) {
                    // This condition allows us to parse the month name for:
                    // 1. the general cases like "yyyy MMMM dd".
                    // 2. prefix in the month name like: "dd '\x05d1'MMMM yyyy" (Hebrew - Israel)
                    result = i;
                    maxLen = index + monthName.Length;
                } else if (str.StartsWith(monthName, true)) {
                    // The condition allows us to get the month name for cultures
                    // which has spaces in their month names.
                    // E.g. 
                    if (monthName.Length > maxLen) {
                        result = i;
                        maxLen = monthName.Length;
                    }
                }
                }
            if (result > -1) {
                str.Index += maxLen;
                return (result);
            }
            for (i = 1; i <= monthInYear; i++)
            {
                if (MatchWord(str, dtfi.GetAbbreviatedMonthName(i), false))
                {
                    return (i);
                }
            }

            //
            // Check the month name in the invariant culture.
            //
            for (i = 1; i <= 12; i++)
            {
                if (MatchWord(str, invariantInfo.GetMonthName(i), false))
                {
                    return (i);
                }
            }

            for (i = 1; i <= 12; i++)
            {
                if (MatchWord(str, invariantInfo.GetAbbreviatedMonthName(i), false))
                {
                    return (i);
                }
            }

            return (-1);
        }
		public static string ToString (DateTime dt, TimeSpan? utc_offset, string format, DateTimeFormatInfo dfi)
		{
			// the length of the format is usually a good guess of the number
			// of chars in the result. Might save us a few bytes sometimes
			// Add + 10 for cases like mmmm dddd
			StringBuilder result = new StringBuilder (format.Length + 10);

			// For some cases, the output should not use culture dependent calendar
			DateTimeFormatInfo inv = DateTimeFormatInfo.InvariantInfo;
			if (format == inv.RFC1123Pattern)
				dfi = inv;
			else if (format == inv.UniversalSortableDateTimePattern)
				dfi = inv;

			int i = 0;

			while (i < format.Length) {
				int tokLen;
				bool omitZeros = false;
				char ch = format [i];

				switch (ch) {

				//
				// Time Formats
				//
				case 'h':
					// hour, [1, 12]
					tokLen = DateTimeUtils.CountRepeat (format, i, ch);

					int hr = dt.Hour % 12;
					if (hr == 0)
						hr = 12;

					DateTimeUtils.ZeroPad (result, hr, tokLen == 1 ? 1 : 2);
					break;
				case 'H':
					// hour, [0, 23]
					tokLen = DateTimeUtils.CountRepeat (format, i, ch);
					DateTimeUtils.ZeroPad (result, dt.Hour, tokLen == 1 ? 1 : 2);
					break;
				case 'm':
					// minute, [0, 59]
					tokLen = DateTimeUtils.CountRepeat (format, i, ch);
					DateTimeUtils.ZeroPad (result, dt.Minute, tokLen == 1 ? 1 : 2);
					break;
				case 's':
					// second [0, 29]
					tokLen = DateTimeUtils.CountRepeat (format, i, ch);
					DateTimeUtils.ZeroPad (result, dt.Second, tokLen == 1 ? 1 : 2);
					break;
				case 'F':
					omitZeros = true;
					goto case 'f';
				case 'f':
					// fraction of second, to same number of
					// digits as there are f's

					tokLen = DateTimeUtils.CountRepeat (format, i, ch);
					if (tokLen > 7)
						throw new FormatException ("Invalid Format String");

					int dec = (int)((long)(dt.Ticks % TimeSpan.TicksPerSecond) / (long) Math.Pow (10, 7 - tokLen));
					int startLen = result.Length;
					DateTimeUtils.ZeroPad (result, dec, tokLen);

					if (omitZeros) {
						while (result.Length > startLen && result [result.Length - 1] == '0')
							result.Length--;
						// when the value was 0, then trim even preceding '.' (!) It is fixed character.
						if (dec == 0 && startLen > 0 && result [startLen - 1] == '.')
							result.Length--;
					}

					break;
				case 't':
					// AM/PM. t == first char, tt+ == full
					tokLen = DateTimeUtils.CountRepeat (format, i, ch);
					string desig = dt.Hour < 12 ? dfi.AMDesignator : dfi.PMDesignator;

					if (tokLen == 1) {
						if (desig.Length >= 1)
							result.Append (desig [0]);
					}
					else
						result.Append (desig);

					break;
				case 'z':
					// timezone. t = +/-h; tt = +/-hh; ttt+=+/-hh:mm
					tokLen = DateTimeUtils.CountRepeat (format, i, ch);
					TimeSpan offset = 
						utc_offset ?? 
						TimeZone.CurrentTimeZone.GetUtcOffset (dt);

					if (offset.Ticks >= 0)
						result.Append ('+');
					else
						result.Append ('-');

					switch (tokLen) {
					case 1:
						result.Append (Math.Abs (offset.Hours));
						break;
					case 2:
						result.Append (Math.Abs (offset.Hours).ToString ("00"));
						break;
					default:
						result.Append (Math.Abs (offset.Hours).ToString ("00"));
						result.Append (':');
						result.Append (Math.Abs (offset.Minutes).ToString ("00"));
						break;
					}
					break;
				case 'K': // 'Z' (UTC) or zzz (Local)
					tokLen = 1;

					if (utc_offset != null || dt.Kind == DateTimeKind.Local) {
						offset = utc_offset ?? TimeZone.CurrentTimeZone.GetUtcOffset (dt);
						if (offset.Ticks >= 0)
							result.Append ('+');
						else
							result.Append ('-');
						result.Append (Math.Abs (offset.Hours).ToString ("00"));
						result.Append (':');
						result.Append (Math.Abs (offset.Minutes).ToString ("00"));
					} else if (dt.Kind == DateTimeKind.Utc)
						result.Append ('Z');
					break;
				//
				// Date tokens
				//
				case 'd':
					// day. d(d?) = day of month (leading 0 if two d's)
					// ddd = three leter day of week
					// dddd+ full day-of-week
					tokLen = DateTimeUtils.CountRepeat (format, i, ch);

					if (tokLen <= 2)
						DateTimeUtils.ZeroPad (result, dfi.Calendar.GetDayOfMonth (dt), tokLen == 1 ? 1 : 2);
					else if (tokLen == 3)
						result.Append (dfi.GetAbbreviatedDayName (dfi.Calendar.GetDayOfWeek (dt)));
					else
						result.Append (dfi.GetDayName (dfi.Calendar.GetDayOfWeek (dt)));

					break;
				case 'M':
					// Month.m(m?) = month # (with leading 0 if two mm)
					// mmm = 3 letter name
					// mmmm+ = full name
					tokLen = DateTimeUtils.CountRepeat (format, i, ch);
					int month = dfi.Calendar.GetMonth(dt);
					if (tokLen <= 2)
						DateTimeUtils.ZeroPad (result, month, tokLen);
					else if (tokLen == 3)
						result.Append (dfi.GetAbbreviatedMonthName (month));
					else
						result.Append (dfi.GetMonthName (month));

					break;
				case 'y':
					// Year. y(y?) = two digit year, with leading 0 if yy
					// yyy+ full year with leading zeros if needed.
					tokLen = DateTimeUtils.CountRepeat (format, i, ch);

					if (tokLen <= 2)
						DateTimeUtils.ZeroPad (result, dfi.Calendar.GetYear (dt) % 100, tokLen);
					else
						DateTimeUtils.ZeroPad (result, dfi.Calendar.GetYear (dt), tokLen);
					break;

				case 'g':
					// Era name
					tokLen = DateTimeUtils.CountRepeat (format, i, ch);
					result.Append (dfi.GetEraName (dfi.Calendar.GetEra (dt)));
					break;

				//
				// Other
				//
				case ':':
					result.Append (dfi.TimeSeparator);
					tokLen = 1;
					break;
				case '/':
					result.Append (dfi.DateSeparator);
					tokLen = 1;
					break;
				case '\'': case '"':
					tokLen = DateTimeUtils.ParseQuotedString (format, i, result);
					break;
				case '%':
					if (i >= format.Length - 1)
						throw new FormatException ("% at end of date time string");
					if (format [i + 1] == '%')
						throw new FormatException ("%% in date string");

					// Look for the next char
					tokLen = 1;
					break;
				case '\\':
					// C-Style escape
					if (i >= format.Length - 1)
						throw new FormatException ("\\ at end of date time string");

					result.Append (format [i + 1]);
					tokLen = 2;

					break;
				default:
					// catch all
					result.Append (ch);
					tokLen = 1;
					break;
				}
				i += tokLen;
			}
			return result.ToString ();
		}
 public static string GetMonthName(int Month)
 {
     DateTimeFormatInfo dfi = new DateTimeFormatInfo();
     string monthName = dfi.GetAbbreviatedMonthName(Month);           
     return monthName;
 }
    protected void GridView_Evaluation_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        int FixCellCount = 9;

        e.Row.Cells[0].Visible = false;

        if (e.Row.RowType == DataControlRowType.Header)
        {
            e.Row.Cells[5].Visible = false;
            e.Row.Cells[6].Visible = false;
            e.Row.Cells[7].Visible = false;
            e.Row.Cells[8].Visible = false;
        }
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            string CrewID = DataBinder.Eval(e.Row.DataItem, "ID").ToString();

            DateTime S_ON_Dt = DateTime.Parse(DataBinder.Eval(e.Row.DataItem, "Sign_On_Date").ToString());
            DateTime COC_Dt  = DateTime.Parse(DataBinder.Eval(e.Row.DataItem, "COC").ToString());
            DateTime St_Dt   = DateTime.Parse(DateTime.Parse(DataBinder.Eval(e.Row.DataItem, "StDate").ToString()).ToString("dd/MM/yyyy"));
            DateTime End_Dt  = DateTime.Parse(DateTime.Parse(DataBinder.Eval(e.Row.DataItem, "EndDate").ToString()).ToString("dd/MM/yyyy"));
            DateTime Cell_Dt;
            int      MonCount = 0;


            for (int i = 0; i < FixCellCount; i++)
            {
                e.Row.Cells[i].CssClass = "Fixed";
                //e.Row.Cells[i].Attributes.Add("onclick", "window.open('../Crew/CrewDetails.aspx?ID=" + CrewID + "');");
            }

            e.Row.Cells[1].Width     = 50;
            e.Row.Cells[2].Width     = 50;
            e.Row.Cells[2].CssClass += " link";
            e.Row.Cells[2].Attributes.Add("onclick", "window.open('../Crew/CrewDetails.aspx?ID=" + CrewID + "');");
            e.Row.Cells[3].Width   = 200;
            e.Row.Cells[4].Width   = 50;
            e.Row.Cells[5].Visible = false;
            e.Row.Cells[6].Visible = false;
            e.Row.Cells[7].Visible = false;
            e.Row.Cells[8].Visible = false;

            S_ON_Dt = S_ON_Dt.AddDays(-1 * S_ON_Dt.Day);
            COC_Dt  = COC_Dt.AddDays(-1 * COC_Dt.Day).AddMonths(1);

            for (int i = FixCellCount; i < e.Row.Cells.Count; i++)
            {
                e.Row.Cells[i].Width = 50;

                Cell_Dt = St_Dt.AddMonths(MonCount);

                MonCount++;

                if (Cell_Dt.Month == DateTime.Today.Month && Cell_Dt.Year == DateTime.Today.Year)
                {
                    e.Row.Cells[i].CssClass += " ThisMonth";
                }

                System.Globalization.DateTimeFormatInfo mfi = new
                                                              System.Globalization.DateTimeFormatInfo();
                string strMonthName = mfi.GetAbbreviatedMonthName(Cell_Dt.Month).ToString();

                strMonthName += ' ' + Cell_Dt.Year.ToString();
                if (DataBinder.Eval(e.Row.DataItem, strMonthName).ToString() != "")
                {
                    if (Cell_Dt >= S_ON_Dt && Cell_Dt <= COC_Dt)
                    {
                        e.Row.Cells[i].CssClass = " Current";
                        e.Row.Cells[i].Attributes.Add("onclick", "window.open('CrewEvaluations.aspx?CrewID=" + CrewID + "');");
                    }
                }
                if (e.Row.Cells[i].Text.Trim() == "Completed")
                {
                    //e.Row.Cells[i].Attributes.Add("onclick", "window.open('CrewEvaluations.aspx?CrewID=" + CrewID + "');");
                    e.Row.Cells[i].CssClass += " Complete";
                }
                else if (e.Row.Cells[i].Text.Trim() == "Pending")
                {
                    //e.Row.Cells[i].Attributes.Add("onclick", "window.open('CrewEvaluations.aspx?CrewID=" + CrewID + "');");
                    e.Row.Cells[i].CssClass += " Pending";
                }
                else if (e.Row.Cells[i].Text.Trim() == "Overdue")
                {
                    //e.Row.Cells[i].Attributes.Add("onclick", "window.open('CrewEvaluations.aspx?CrewID=" + CrewID + "');");
                    e.Row.Cells[i].CssClass += " overdue";
                    e.Row.Cells[i].Text      = "Pending";
                }

                //e.Row.Cells[i].ToolTip = "";
            }
        }
    }
Exemple #18
0
        private void BindControls()
        {
            List<CMEDTimeZone> timezones = controller.GetTimeZones();
            lstTimeZone.DataSource = timezones;
            lstTimeZone.DataTextField = "timezone_title";
            lstTimeZone.DataValueField = "timezone_code";
            lstTimeZone.DataBind();

            List<int> BDayNumbers = Enumerable.Range(1, 31).ToList();

            BDay.DataSource = BDayNumbers;
            BDay.DataBind();

            List<int> BMonthNumbers = Enumerable.Range(1, 12).ToList();

            BMonth.DataSource = BMonthNumbers;
            BMonth.DataBind();

            List<int> BYearNumbers = Enumerable.Range(1900, DateTime.Now.Year + 1 - 1900).ToList();

            BYear.DataSource = BYearNumbers;
            BYear.DataBind();

            List<int> BHourNumbers = Enumerable.Range(1, 12).ToList();

            foreach (int hour in BHourNumbers)
            {
                BHour.Items.Add(new ListItem(hour.ToString("00"), hour.ToString()));
            }

            DateTimeFormatInfo mfi = new DateTimeFormatInfo();
            foreach (int hour in BHourNumbers)
            {
                string strMonthName = mfi.GetAbbreviatedMonthName(hour);
                BeginDate.Items.Add(new ListItem(strMonthName, strMonthName));
            }

            List<int> BMinNumbers = Enumerable.Range(1, 59).ToList();
            foreach (int hour in BMinNumbers)
            {
                BMin.Items.Add(new ListItem(hour.ToString("00"), hour.ToString()));
            }

            AMPM.Items.Add(new ListItem("AM", "AM"));
            AMPM.Items.Add(new ListItem("PM", "PM"));

            Gender.Items.Add(new ListItem("Female", "Female"));
            Gender.Items.Add(new ListItem("Male", "Male"));
        }
 private static string FormatHebrewMonthName(DateTime time, int month, int repeatCount, DateTimeFormatInfo dtfi)
 {
     if (dtfi.Calendar.IsLeapYear(dtfi.Calendar.GetYear(time)))
     {
         return dtfi.internalGetMonthName(month, MonthNameStyles.LeapYear, repeatCount == 3);
     }
     if (month >= 7)
     {
         month++;
     }
     if (repeatCount == 3)
     {
         return dtfi.GetAbbreviatedMonthName(month);
     }
     return dtfi.GetMonthName(month);
 }
Exemple #20
0
        //
        //  FormatHebrewMonthName
        //
        //  Action: Return the Hebrew month name for the specified DateTime.
        //  Returns: The month name string for the specified DateTime.
        //  Arguments: 
        //        time   the time to format
        //        month  The month is the value of HebrewCalendar.GetMonth(time).         
        //        repeat Return abbreviated month name if repeat=3, or full month name if repeat=4
        //        dtfi    The DateTimeFormatInfo which uses the Hebrew calendars as its calendar.
        //  Exceptions: None.
        // 
        
        /* Note:
            If DTFI is using Hebrew calendar, GetMonthName()/GetAbbreviatedMonthName() will return month names like this:            
            1   Hebrew 1st Month
            2   Hebrew 2nd Month
            ..  ...
            6   Hebrew 6th Month
            7   Hebrew 6th Month II (used only in a leap year)
            8   Hebrew 7th Month
            9   Hebrew 8th Month
            10  Hebrew 9th Month
            11  Hebrew 10th Month
            12  Hebrew 11th Month
            13  Hebrew 12th Month

            Therefore, if we are in a regular year, we have to increment the month name if moth is greater or eqaul to 7.            
        */
        private static String FormatHebrewMonthName(DateTime time, int month, int repeatCount, DateTimeFormatInfo dtfi)
        {
            Contract.Assert(repeatCount != 3 || repeatCount != 4, "repeateCount should be 3 or 4");
            if (dtfi.Calendar.IsLeapYear(dtfi.Calendar.GetYear(time))) {
                // This month is in a leap year
                return (dtfi.internalGetMonthName(month, MonthNameStyles.LeapYear, (repeatCount == 3)));
            }
            // This is in a regular year.
            if (month >= 7) {
                month++;
            }
            if (repeatCount == 3) {
                return (dtfi.GetAbbreviatedMonthName(month));
            }
            return (dtfi.GetMonthName(month));
        }
 private static string FormatMonth(int month, int repeatCount, DateTimeFormatInfo dtfi)
 {
     if (repeatCount == 3)
     {
         return dtfi.GetAbbreviatedMonthName(month);
     }
     return dtfi.GetMonthName(month);
 }
		private static bool MatchAbbreviatedMonthName(ref __DTString str, DateTimeFormatInfo dtfi, ref int result)
		{
			int num = 0;
			result = -1;
			if (str.GetNext())
			{
				int num2 = (dtfi.GetMonthName(13).Length == 0) ? 12 : 13;
				for (int i = 1; i <= num2; i++)
				{
					string abbreviatedMonthName = dtfi.GetAbbreviatedMonthName(i);
					int length = abbreviatedMonthName.Length;
					if ((dtfi.HasSpacesInMonthNames ? str.MatchSpecifiedWords(abbreviatedMonthName, false, ref length) : str.MatchSpecifiedWord(abbreviatedMonthName)) && length > num)
					{
						num = length;
						result = i;
					}
				}
				if ((dtfi.FormatFlags & DateTimeFormatFlags.UseLeapYearMonth) != DateTimeFormatFlags.None)
				{
					int num3 = str.MatchLongestWords(dtfi.internalGetLeapYearMonthNames(), ref num);
					if (num3 >= 0)
					{
						result = num3 + 1;
					}
				}
			}
			if (result > 0)
			{
				str.Index += num - 1;
				return true;
			}
			return false;
		}
Exemple #23
0
 private static String FormatHebrewMonthName(DateTime time, int month, int repeatCount, DateTimeFormatInfo dtfi)
 {
     if (!dtfi.Calendar.IsLeapYear(dtfi.Calendar.GetYear(time)) && (month >= 7)) {
         month++;
     }
     if (repeatCount == 3) {
         return (dtfi.GetAbbreviatedMonthName(month));
     }
     return (dtfi.GetMonthName(month));
 }