Ejemplo n.º 1
0
        private TableRow CreateDayHeader(DateTime firstDay, DateTime visibleDate, System.Globalization.Calendar threadCalendar)
        {
            TableRow row = new TableRow();

            DateTimeFormatInfo dtf = DateTimeFormatInfo.CurrentInfo;

            TableItemStyle dayNameStyle = new TableItemStyle();

            dayNameStyle.HorizontalAlign = HorizontalAlign.Center;
            dayNameStyle.CopyFrom(DayHeaderStyle);
            DayNameFormat dayNameFormat = DayNameFormat;

            int numericFirstDay = (int)threadCalendar.GetDayOfWeek(firstDay);

            for (int i = numericFirstDay; i < numericFirstDay + 7; i++)
            {
                string dayName;
                int    dayOfWeek = i % 7;
                switch (dayNameFormat)
                {
                case DayNameFormat.FirstLetter:
                    dayName = dtf.GetDayName((DayOfWeek)dayOfWeek).Substring(0, 1);
                    break;

                case DayNameFormat.FirstTwoLetters:
                    dayName = dtf.GetDayName((DayOfWeek)dayOfWeek).Substring(0, 2);
                    break;

                case DayNameFormat.Full:
                    dayName = dtf.GetDayName((DayOfWeek)dayOfWeek);
                    break;

                case DayNameFormat.Short:
                    dayName = dtf.GetAbbreviatedDayName((DayOfWeek)dayOfWeek);
                    break;

                case DayNameFormat.Shortest:
                    dayName = dtf.GetShortestDayName((DayOfWeek)dayOfWeek);
                    break;

                default:
                    System.Diagnostics.Debug.Assert(false, "Unknown DayNameFormat value!");

                    goto
                case DayNameFormat.Short;
                }

                TableCell cell = new TableCell();
                cell.ApplyStyle(dayNameStyle);
                cell.Text = dayName;
                row.Cells.Add(cell);
            }
            return(row);
        }
Ejemplo n.º 2
0
        public static bool TryParseUserTime(string s, out DateTime result)
        {
            DateTime time;

            if (TryParseCTCPTime(s, DateTimeStyles.NoCurrentDateDefault, out time))
            {
                if (time.Year == 1)
                {
                    // If they didn't specify a date, we add our own code.
                    result = new DateTime(999, 1, 3, time.Hour, time.Minute, time.Second, time.Millisecond);
                }
                else
                {
                    result = time;
                }
                return(true);
            }

            // If they specified a day of the week but no date, handle it specially.
            DateTimeFormatInfo format = DateTimeFormatInfo.CurrentInfo;

            s = s.TrimStart();
            DayOfWeek day;

            for (day = DayOfWeek.Sunday; day <= DayOfWeek.Saturday; ++day)
            {
                if (s.StartsWith(format.GetDayName(day)))
                {
                    s = s.Substring(format.GetDayName(day).Length);
                    break;
                }
                if (s.StartsWith(format.GetAbbreviatedDayName(day)))
                {
                    s = s.Substring(format.GetAbbreviatedDayName(day).Length);
                    break;
                }
            }
            if ((int)day == 7)
            {
                result = default(DateTime);
                return(false);
            }

            if (!TryParseCTCPTime(s, DateTimeStyles.NoCurrentDateDefault, out time) || time.Year != 1)
            {
                result = default(DateTime);
                return(false);
            }
            result = new DateTime(999, 1, 6 + (int)day, time.Hour, time.Minute, time.Second, time.Millisecond);
            return(true);
        }
        public string GetNameDayText(DateTime date)
        {
            var yesterday          = date.AddDays(-1);
            var yesterdaysNameDays = GetHungarianNameDay(yesterday);
            var todaysNameDays     = GetHungarianNameDay(date);
            var tommorow           = date.AddDays(1);
            var tommorowsNameDays  = GetHungarianNameDay(tommorow);

            var mfi = new DateTimeFormatInfo();

            return(String.Format("Tegnap ({4}) {0} névnapja volt.{3}Ma ({5}) {1} névnapja van.{3}Holnap ({6}) {2} névnapja lesz.",
                                 yesterdaysNameDays, todaysNameDays, tommorowsNameDays, Environment.NewLine,
                                 mfi.GetDayName(yesterday.DayOfWeek), mfi.GetDayName(date.DayOfWeek), mfi.GetDayName(tommorow.DayOfWeek)));
        }
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var _date = System.Convert.ToDateTime(value);
            DateTimeFormatInfo datetimeInfo = culture.DateTimeFormat;

            return(datetimeInfo.GetDayName(_date.DayOfWeek).ToUpper() + " " + _date.Day + " DE " + datetimeInfo.MonthNames[_date.Month].ToUpper() + ", " + _date.Year);
        }
Ejemplo n.º 5
0
        public static String data_extenso(DateTime value)
        {
            CultureInfo        culture = new CultureInfo("pt-BR");
            DateTimeFormatInfo dtfi    = culture.DateTimeFormat;

            return(dtfi.GetDayName(value.DayOfWeek) + ", " + (value.Day) + " " + dtfi.GetMonthName(value.Month) + " de " + (value.Year));
        }
Ejemplo n.º 6
0
        public static Calendario PreencheMes(int Mes, int Ano, SqlGeneric sqlServices, ContextPage contexto, string idProfissional)
        {
            Calendario         retorno    = new Calendario();
            CultureInfo        culture    = new CultureInfo("pt-BR");
            DateTimeFormatInfo dataFormat = culture.DateTimeFormat;

            int qtdDiasMes = DateTime.DaysInMonth(Ano, Mes);

            retorno.ano     = Ano;
            retorno.mes     = Mes;
            retorno.nomeMes = dataFormat.MonthNames[Mes - 1];
            retorno.qtdDias = qtdDiasMes;

            List <Dia>         diasMEs      = new List <Dia>();
            List <Agendamento> Agendamentos = sqlServices.RetornaAgendamentosMes(Mes.ToString(), Ano.ToString(), idProfissional, contexto.idOrganizacao.ToString());

            //Preenche todos o dias do Mes
            for (int i = 1; i <= qtdDiasMes; i++)
            {
                DateTime dataRef = new DateTime(Ano, Mes, i);
                Dia      dia     = new Dia();
                dia.dia             = i;
                dia.nomeDia         = dataFormat.GetDayName(dataRef.DayOfWeek);
                dia.itensCalendario = PreencheItemCalendario(i, Agendamentos);
                diasMEs.Add(dia);
            }
            retorno.dias = diasMEs;

            SqlGenericData sqlData = new SqlGenericData();

            retorno.profissionais = HelperAttributes.PreencheDropDownList(sqlData.RetornaTodasRelacaoProfissional(contexto.idOrganizacao));

            return(retorno);
        }
    private bool VerificationHelper(DateTimeFormatInfo info, string[] expected, string errorno)
    {
        bool retval = true;

        DayOfWeek[] values = new DayOfWeek[] {
            DayOfWeek.Sunday,
            DayOfWeek.Monday,
            DayOfWeek.Tuesday,
            DayOfWeek.Wednesday,
            DayOfWeek.Thursday,
            DayOfWeek.Friday,
            DayOfWeek.Saturday
        };

        for (int i = 0; i < values.Length; ++i)
        {
            string actual = info.GetDayName(values[i]);
            if (actual != expected[i])
            {
                TestLibrary.TestFramework.LogError(errorno, "GetDayName returns wrong value");
                TestLibrary.TestFramework.LogInformation("WARNING[LOCAL VARIABLES] values[i] = " + values[i] + ", expected[i] = " + expected[i] + ", actual = " + actual);
                retval = false;
            }
        }

        return(retval);
    }
Ejemplo n.º 8
0
        private void BindControls()
        {
            cbEnableAlerts.Checked = true;
            cbEnableAlerts.DataBind();
            cbShowNextTime.DataBind();
            s2ApplyLocalization();

            s3Title1.Text          = HttpUtility.HtmlDecode(PortalConfig.PortalHomepageTitle1);
            s3Title2.Text          = HttpUtility.HtmlDecode(PortalConfig.PortalHomepageTitle2);
            s3Text1.Text           = HttpUtility.HtmlDecode(PortalConfig.PortalHomepageText1);
            s3Text2.Text           = HttpUtility.HtmlDecode(PortalConfig.PortalHomepageText2);
            cbEnableAlerts.Checked = PortalConfig.EnableAlerts;
            int index = (int)PortalConfig.PortalFirstDayOfWeek;

            DateTimeFormatInfo dtf = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat;

            for (int i = 0; i < 7; i++)
            {
                ddFDOW.Items.Add(new ListItem(dtf.GetDayName((DayOfWeek)i), i.ToString()));
            }
            CommonHelper.SafeSelect(ddFDOW, index.ToString());
            if (Mediachase.IbnNext.TimeTracking.TimeTrackingBlock.GetTotalCount() > 0)
            {
                fsFDOW.Visible = false;
            }
        }
Ejemplo n.º 9
0
        private string GetDiaSemana(DateTime data)
        {
            CultureInfo        culture = new CultureInfo("pt-BR");
            DateTimeFormatInfo dtfi    = culture.DateTimeFormat;

            return(dtfi.GetDayName(data.DayOfWeek));
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Format <see cref="BirthDate.Day"/> and append the format-result to the <paramref name="result"/>
        /// and return the length of the token.
        /// </summary>
        /// <remarks>
        /// The formatted day will be:
        ///  - If <see cref="BirthDateFormatInfo.MaskDay"/> is true, masked with the same length as token, with
        ///    <see cref="BirthDateFormatInfo.NumberMaskChar"/> (Token Length &lt;= 2) or
        ///    <see cref="BirthDateFormatInfo.TextMaskChar"/> (Token Length &gt; 2).
        ///  - Token length = 1: (Day mod 100) without leading zero.
        ///  - Token length = 2: (Day mod 100) with leading zero.
        ///  - Token length = 3: Day name abbreviated as 3 characters.
        ///  - Token length > 3: Day name (not abbreviated).
        /// </remarks>
        /// <param name="result">The result.</param>
        /// <param name="format">The format.</param>
        /// <param name="pos">The position.</param>
        /// <param name="day">The day.</param>
        /// <param name="dateTime">The date time.</param>
        /// <returns></returns>
        private int FormatDay(StringBuilder result, string format, int pos, int day, DateTime dateTime)
        {
            int tokenLen = FormatHelper.ParseLengthOfRepeatPattern(format, pos, 'd');

            if (tokenLen <= 2)
            {
                // tokenLen == 1 : Day of month as digits with no leading zero.
                // tokenLen == 2 : Day of month as digits with leading zero for single-digit months.
                FormatHelper.FormatDigits(result, day, tokenLen, _birthDateFormatInfo.MaskDay, _birthDateFormatInfo.NumberMaskChar);
            }
            else if (tokenLen == 3 && !_birthDateFormatInfo.MaskDay)
            {
                // tokenLen == 3 : Day of week as a three-leter abbreviation.
                int dayOfWeek = (int)_calendar.GetDayOfWeek(dateTime);
                result.Append(_dateTimeFormatInfo.GetAbbreviatedDayName((DayOfWeek)dayOfWeek));
            }
            else if (!_birthDateFormatInfo.MaskDay)
            {
                // tokenLen >= 4 : Day of week as its full name.
                int dayOfWeek = (int)_calendar.GetDayOfWeek(dateTime);
                result.Append(_dateTimeFormatInfo.GetDayName((DayOfWeek)dayOfWeek));
            }
            else
            {
                result.Append("".PadLeft(tokenLen, _birthDateFormatInfo.TextMaskChar));
            }

            return(tokenLen);
        }
Ejemplo n.º 11
0
        private void mensagemWatsappToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string NomeCliente = Convert.ToString(DGVDADOS.SelectedRows[0].Cells["NOME"].Value);
            var    ClienteTela = new CLIENTEDAL().CONSULTATODOSPELONOME(NomeCliente);

            if (ClienteTela.TELEFONE1 == null)
            {
                MessageBoxEx.Show("Cliente não tem telefone cadastrado!"); return;
            }
            if (!string.IsNullOrEmpty(ClienteTela.TELEFONE1.ToString()))
            {
                DateTime           data    = Convert.ToDateTime(DGVDADOS.SelectedRows[0].Cells["DATA_VENCIMENTO"].Value);
                CultureInfo        culture = new CultureInfo("pt-BR");
                DateTimeFormatInfo dtfi    = culture.DateTimeFormat;
                int    dia             = data.Day;
                int    ano             = data.Year;
                string mes             = culture.TextInfo.ToTitleCase(dtfi.GetMonthName(data.Month));
                string diasemana       = culture.TextInfo.ToTitleCase(dtfi.GetDayName(data.DayOfWeek));
                string dataDesmenbrada = dia + " / " + mes + " / " + ano;

                Link.Text = @"https://api.whatsapp.com/send?phone=55" + ClienteTela.TELEFONE1.ToString().Replace(" ", "").Replace("-", "").Replace("(", "").Replace(")", "") + "&text=Ola(" + ClienteTela.NOME.ToString() + " )" +
                            "Consta em nossos cadastros que o pagamento referente (ao aluguel), (Mês de " + mes + ") . Com vencimento na data ( " + dataDesmenbrada + "), ainda está em aberto." +
                            "Valor da mensalidade R$: " + DGVDADOS.SelectedRows[0].Cells["VALOR"].Value + "." +
                            "Caso tenha alguma dúvida ou oposição ao processo e também haja interesse em realizar a quitação do valor," +
                            "   peço que entre em contato por um dos números ficaremos felizes em atendê-lo." +
                            "Atenciosamente " +
                            "Setor Administrativo JB aluguéis";
                //enviar watsap
                System.Diagnostics.Process pStart = new System.Diagnostics.Process();
                pStart.StartInfo = new System.Diagnostics.ProcessStartInfo(Link.Text);
                pStart.Start();
            }
        }
Ejemplo n.º 12
0
        private void FillListBox()
        {
            string             culture = cboCulture.SelectedItem.ToString();
            CultureInfo        ci      = new CultureInfo(culture);
            DateTimeFormatInfo dtfi    = new DateTimeFormatInfo();

            dtfi = ci.DateTimeFormat;

            DateTime dt;

            lstMonth.Items.Clear();

            for (int i = 1; i <= 12; i++)
            {
                dt = new DateTime(1900, i, 1);
                lstMonth.Items.Add(dt.ToString("MMMM", ci));
            }

            lstWeek.Items.Clear();


            for (DayOfWeek i = DayOfWeek.Sunday; i <= DayOfWeek.Saturday; i++)
            {
                lstWeek.Items.Add(dtfi.GetDayName(i));
            }
        }
Ejemplo n.º 13
0
        private void BindDG(int CalendarID)
        {
            dgCalendar.Columns[1].HeaderText = LocRM.GetString("WeekDays");
            dgCalendar.Columns[2].HeaderText = LocRM.GetString("WorkTimeIntervals");

            DateTimeFormatInfo dtf = CultureInfo.CurrentCulture.DateTimeFormat;

            DataTable dt = new DataTable();

            dt.Columns.Add("DayOfWeek", typeof(int));
            dt.Columns.Add("DayTitle");
            dt.Columns.Add("Intervals");

            int fdw = (int)dtf.FirstDayOfWeek;

            for (int i = 1; i <= 7; i++)
            {
                DataRow dr = dt.NewRow();
                if (fdw == 7)
                {
                    fdw = 0;
                }

                dr["DayOfWeek"] = FromUsaToRus(fdw);
                dr["DayTitle"]  = dtf.GetDayName((DayOfWeek)fdw) + ":";

                string intervals = "";
                using (IDataReader rdr = cal.GetListWeekdayHours(CalendarID, (byte)(FromUsaToRus(fdw))))
                {
                    while (rdr.Read())
                    {
                        if (intervals != "")
                        {
                            intervals += "<br/>";
                        }
                        int _fromtime = (int)rdr["FromTime"];
                        int _totime   = (int)rdr["ToTime"];

                        DateTime fromtime = ParseMin(_fromtime);
                        DateTime totime   = ParseMin(_totime);

                        intervals += fromtime.ToShortTimeString() + " - " + totime.ToShortTimeString();
                    }
                }

                if (intervals == "")
                {
                    intervals = LocRM.GetString("Empty");
                }


                dr["Intervals"] = intervals;

                fdw++;

                dt.Rows.Add(dr);
            }
            dgCalendar.DataSource = dt.DefaultView;
            dgCalendar.DataBind();
        }
        public string ObterNomeDataDia(DateTime data)
        {
            CultureInfo        culture  = new CultureInfo("pt-BR");
            DateTimeFormatInfo dtfi     = culture.DateTimeFormat;
            string             datanome = dtfi.GetDayName(data.DayOfWeek);

            return(datanome);
        }
Ejemplo n.º 15
0
        public string VerificaSemana(DateTime data)
        {
            CultureInfo        culture = new CultureInfo("pt-BR");
            DateTimeFormatInfo dtfi    = culture.DateTimeFormat;
            string             data1   = dtfi.GetDayName(data.DayOfWeek);

            return(data1);
        }
Ejemplo n.º 16
0
        private string getDiaDaSemana()
        {
            CultureInfo        culture     = new CultureInfo("pt-BR");
            DateTimeFormatInfo dtfi        = culture.DateTimeFormat;
            string             diaDaSemana = dtfi.GetDayName(dtpFestaData.Value.DayOfWeek);

            return(diaDaSemana);
        }
 // Token: 0x060015E0 RID: 5600 RVA: 0x00040577 File Offset: 0x0003E777
 private static string FormatDayOfWeek(int dayOfWeek, int repeat, DateTimeFormatInfo dtfi)
 {
     if (repeat == 3)
     {
         return(dtfi.GetAbbreviatedDayName((DayOfWeek)dayOfWeek));
     }
     return(dtfi.GetDayName((DayOfWeek)dayOfWeek));
 }
Ejemplo n.º 18
0
        /// <summary>
        /// Gets the abbreviated or full day name for the specified <see cref="DayOfWeek"/> value using,
        /// if not null, the <paramref name="nameProvider"/> or the <see cref="DateTimeFormatInfo"/> specified by <paramref name="info"/>.
        /// </summary>
        /// <param name="dayofweek">The <see cref="DayOfWeek"/> value to get the day name for.</param>
        /// <param name="info">The <see cref="DateTimeFormatInfo"/> to get the name.</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 day name; false otherwise.</param>
        /// <returns>The full or abbreviated day name specified by <paramref name="dayofweek"/> value.</returns>
        private static string GetDayName(DayOfWeek dayofweek, DateTimeFormatInfo info, ICustomFormatProvider nameProvider, bool abbreviated)
        {
            if (nameProvider != null)
            {
                return(abbreviated ? nameProvider.GetAbbreviatedDayName(dayofweek) : nameProvider.GetDayName(dayofweek));
            }

            return(abbreviated ? info.GetAbbreviatedDayName(dayofweek) : info.GetDayName(dayofweek));
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Esse método retorna a 3 primeiras letras do dia atual da semana
        /// </summary>
        /// <returns>string contendo o dia da semana</returns>
        public static string GetDiaDaSemana()
        {
            CultureInfo        culture = new CultureInfo("pt-BR");
            DateTimeFormatInfo dtfi    = culture.DateTimeFormat;

            string diaAtual = dtfi.GetDayName(DateTime.Now.DayOfWeek);

            return(diaAtual.Substring(0, 3).ToUpper());
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Returns the internationalised name of the weekday dependent on the setting of the 'Abbreviate' flag.
        /// </summary>
        /// <param name="month">The weekday number - 1 to 7.</param>
        /// <returns>The internationalised name of the weekday, short or long.</returns>
        private string GetDayName(DayOfWeek day)
        {
            if (abbreviate)
            {
                return(dateTimeInfo.GetAbbreviatedDayName(day));
            }

            return(dateTimeInfo.GetDayName(day));
        }
Ejemplo n.º 21
0
        public static Dia PreencheDia(int Ano, int Mes, int dia, SqlGeneric sqlServices, ContextPage contexto, string idProfissional)
        {
            string data = Ano + "-" + Mes + "- " + dia;

            Dia                retorno    = new Dia();
            CultureInfo        culture    = new CultureInfo("pt-BR");
            DateTime           dataRef    = new DateTime(Ano, Mes, dia);
            DateTimeFormatInfo dataFormat = culture.DateTimeFormat;

            retorno.nomeDia = dataFormat.GetDayName(dataRef.DayOfWeek);
            retorno.dia     = dia;
            retorno.ano     = Ano;
            retorno.nomeMes = dataFormat.MonthNames[Mes - 1];

            SqlGenericData            sqldata      = new SqlGenericData();
            IEnumerable <Agendamento> Atendimentos = sqlServices.RetornaAgendamentosDia(data, idProfissional, contexto.idOrganizacao.ToString());

            List <ItemCalendario> lancamentos = new List <ItemCalendario>();


            foreach (var item in Atendimentos)
            {
                ItemCalendario hoc = new ItemCalendario();
                hoc.id             = item.id.ToString();
                hoc.codigo         = item.codigo;
                hoc.inicio         = new ItemHoraDia();
                hoc.inicio.horaDia = (CustomEnum.itemHora)item.horaInicio;
                hoc.fim            = new ItemHoraDia();
                hoc.fim.horaDia    = (CustomEnum.itemHora)item.horaFim;

                hoc.cliente = sqldata.RetornaRelacaoCliente(item.idCliente).idName;
                hoc.tipo    = item.tipoReferencia.ToString();

                if (item.tipoReferencia == CustomEnum.TipoReferencia.OrdemServico)
                {
                    hoc.referencia = sqldata.RetornaRelacaoOrdemServico(item.idReferencia).codigo;
                }
                if (item.tipoReferencia == CustomEnum.TipoReferencia.Servico)
                {
                    hoc.referencia = sqldata.RetornaRelacaoServico(item.idReferencia).codigo;
                }

                if (item.tipoReferencia == CustomEnum.TipoReferencia.Atendimento)
                {
                    hoc.referencia = "";
                }

                lancamentos.Add(hoc);
            }

            retorno.itensCalendario = lancamentos;


            return(retorno);
        }
Ejemplo n.º 22
0
 private static String FormatDayOfWeek(int dayOfWeek, int repeat, DateTimeFormatInfo dtfi)
 {
     Contract.Assert(dayOfWeek >= 0 && dayOfWeek <= 6, "dayOfWeek >= 0 && dayOfWeek <= 6");
     if (repeat == 3)
     {
         return(dtfi.GetAbbreviatedDayName((DayOfWeek)dayOfWeek));
     }
     // Call dtfi.GetDayName() here, instead of accessing DayNames property, because we don't
     // want a clone of DayNames, which will hurt perf.
     return(dtfi.GetDayName((DayOfWeek)dayOfWeek));
 }
Ejemplo n.º 23
0
        public static string WeekdayName(int Weekday,
                                         [Optional, DefaultParameterValue(false)] bool Abbreviate,
                                         [Optional, DefaultParameterValue(FirstDayOfWeek.System)]
                                         FirstDayOfWeek FirstDayOfWeekValue)
        {
            string abbreviatedDayName;

            if ((Weekday < 1) || (Weekday > 7))
            {
                throw new ArgumentException(Utils.GetResourceString("Argument_InvalidValue1", new string[] { "Weekday" }));
            }
            if ((FirstDayOfWeekValue < FirstDayOfWeek.System) || (FirstDayOfWeekValue > FirstDayOfWeek.Saturday))
            {
                throw new ArgumentException(Utils.GetResourceString("Argument_InvalidValue1", new string[] { "FirstDayOfWeekValue" }));
            }
            DateTimeFormatInfo format = (DateTimeFormatInfo)Utils.GetCultureInfo().GetFormat(typeof(DateTimeFormatInfo));

            if (FirstDayOfWeekValue == FirstDayOfWeek.System)
            {
                FirstDayOfWeekValue = (FirstDayOfWeek)(format.FirstDayOfWeek + 1);
            }
            try
            {
                if (Abbreviate)
                {
                    abbreviatedDayName = format.GetAbbreviatedDayName((DayOfWeek)(((Weekday + (int)FirstDayOfWeekValue) - 2) % 7));
                }
                else
                {
                    abbreviatedDayName = format.GetDayName((DayOfWeek)(((Weekday + (int)FirstDayOfWeekValue) - 2) % 7));
                }
            }
            catch (StackOverflowException exception)
            {
                throw exception;
            }
            catch (OutOfMemoryException exception2)
            {
                throw exception2;
            }
            catch (ThreadAbortException exception3)
            {
                throw exception3;
            }
            catch (Exception)
            {
                throw new ArgumentException(Utils.GetResourceString("Argument_InvalidValue1", new string[] { "Weekday" }));
            }
            if (abbreviatedDayName.Length == 0)
            {
                throw new ArgumentException(Utils.GetResourceString("Argument_InvalidValue1", new string[] { "Weekday" }));
            }
            return(abbreviatedDayName);
        }
        public static string ToDateAndfWeekText(this DateTime date)
        {
            CultureInfo        culture        = new CultureInfo("pt-BR");
            DateTimeFormatInfo dateTimeFormat = culture.DateTimeFormat;

            string month     = culture.TextInfo.ToTitleCase(dateTimeFormat.GetMonthName(date.Month));
            string dayOfWeek = culture.TextInfo.ToTitleCase(dateTimeFormat.GetDayName(date.DayOfWeek));

            string data = dayOfWeek + ", " + date.Day + " de " + month + " de " + date.Year;

            return(data);
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Gets day name.
        /// </summary>
        /// <param name="day"></param>
        /// <param name="abbreviate"></param>
        /// <param name="provider"></param>
        /// <returns></returns>
        public static string GetDayName(int day, bool abbreviate, IFormatProvider provider)
        {
            DateTimeFormatInfo info = DateTimeFormatInfo.GetInstance(provider);
            DateTime           date = new DateTime(DateTime.UtcNow.Year, DateTime.UtcNow.Month, day);

            if (abbreviate)
            {
                return(info.GetAbbreviatedDayName(date.DayOfWeek));
            }

            return(info.GetDayName(date.DayOfWeek));
        }
Ejemplo n.º 26
0
        public string DataPorExtenso(DateTime data)
        {
            DateTimeFormatInfo dtfi = culture.DateTimeFormat;

            int    dia       = data.Day;
            int    ano       = data.Year;
            string mes       = culture.TextInfo.ToTitleCase(dtfi.GetMonthName(data.Month));
            string diasemana = culture.TextInfo.ToTitleCase(dtfi.GetDayName(data.DayOfWeek));
            string hora      = data.ToString("hh:mm:ss tt");

            return(diasemana + ", " + dia + " de " + mes + " de " + ano + " as " + hora);
        }
        private string GetNameDayOfWeek(DayOfWeek dayOfWeek)
        {
            CultureInfo rusCulture = CultureInfo.GetCultureInfo("ru-Ru");

            DateTimeFormatInfo tmp = rusCulture.DateTimeFormat;

            string result = tmp.GetDayName(dayOfWeek);

            result = char.ToUpper(result[0]) + result.Substring(1);

            return(result);
        }
Ejemplo n.º 28
0
    public void DataExtenso()
    {
        CultureInfo        culture = new CultureInfo("pt-BR");
        DateTimeFormatInfo dtfi    = culture.DateTimeFormat;
        int    dia       = DateTime.Now.Day;
        int    ano       = DateTime.Now.Year;
        string mes       = culture.TextInfo.ToTitleCase(dtfi.GetMonthName(DateTime.Now.Month));
        string diasemana = culture.TextInfo.ToTitleCase(dtfi.GetDayName(DateTime.Now.DayOfWeek));
        string data      = diasemana + ", " + dia + " de " + mes + " de " + ano;

        lblDataExtenso.Text = data;
    }
Ejemplo n.º 29
0
        string DataAtual()
        {
            CultureInfo        culture = new CultureInfo("pt-BR");
            DateTimeFormatInfo dtfi    = culture.DateTimeFormat;

            int    dia       = DateTime.Now.Day;
            int    ano       = DateTime.Now.Year;
            string mes       = culture.TextInfo.ToTitleCase(dtfi.GetMonthName(DateTime.Now.Month));
            string diasemana = culture.TextInfo.ToTitleCase(dtfi.GetDayName(DateTime.Now.DayOfWeek));

            return(diasemana + ", " + dia + " de " + mes + " de " + ano);
        }
Ejemplo n.º 30
0
        /// <summary>
        /// Gets the string representation for a particular day in the week.
        /// </summary>
        /// <param name="weekDay">Specifies the day of the week.</param>
        /// <returns>the string representation for the specified day.</returns>
        internal protected virtual string GetDayHeaderString(int weekDay)
        {
            DateTimeFormatInfo dateLocalInfo = this.Calendar.DateTimeFormat;
            DayNameFormat      dayFormat     = this.Calendar.DayNameFormat;
            string             dayString     = String.Empty;

            switch (dayFormat)
            {
            case DayNameFormat.Full:
            {
                dayString = dateLocalInfo.GetDayName((DayOfWeek)weekDay);
                break;
            }

            case DayNameFormat.FirstLetter:
            {
                string str = dateLocalInfo.ShortestDayNames[weekDay];
                TextElementEnumerator iter = StringInfo.GetTextElementEnumerator(str);
                iter.MoveNext();
                dayString = iter.Current.ToString();
                break;
            }

            case DayNameFormat.FirstTwoLetters:
            {
                string str = dateLocalInfo.ShortestDayNames[weekDay];
                TextElementEnumerator iter = StringInfo.GetTextElementEnumerator(str);
                iter.MoveNext();
                StringBuilder ftl = new StringBuilder(iter.Current.ToString());
                if (iter.MoveNext())         //in case of Arabic cultures
                {
                    ftl.Append(iter.Current.ToString());
                }
                dayString = ftl.ToString();
                break;
            }

            case DayNameFormat.Short:
            {
                dayString = dateLocalInfo.GetAbbreviatedDayName((DayOfWeek)weekDay);
                break;
            }

            case DayNameFormat.Shortest:
            default:
            {
                dayString = dateLocalInfo.ShortestDayNames[weekDay];
                break;
            }
            }
            return(dayString);
        }
Ejemplo n.º 31
0
        private void VerificationHelper(DateTimeFormatInfo info, string[] expected)
        {
            DayOfWeek[] values = new DayOfWeek[] {
                DayOfWeek.Sunday,
                DayOfWeek.Monday,
                DayOfWeek.Tuesday,
                DayOfWeek.Wednesday,
                DayOfWeek.Thursday,
                DayOfWeek.Friday,
                DayOfWeek.Saturday
            };

            for (int i = 0; i < values.Length; ++i)
            {
                string actual = info.GetDayName(values[i]);
                Assert.Equal(expected[i], actual);
            }
        }
        public void GetDayName(DateTimeFormatInfo format, string[] expected)
        {
            DayOfWeek[] values = new DayOfWeek[]
            {
                DayOfWeek.Sunday,
                DayOfWeek.Monday,
                DayOfWeek.Tuesday,
                DayOfWeek.Wednesday,
                DayOfWeek.Thursday,
                DayOfWeek.Friday,
                DayOfWeek.Saturday
            };

            for (int i = 0; i < values.Length; ++i)
            {
                Assert.Equal(expected[i], format.GetDayName(values[i]));
            }
        }
    private bool VerificationHelper(DateTimeFormatInfo info, string[] expected, string errorno)
    {
        bool retval = true;

        DayOfWeek[] values = new DayOfWeek[] {
            DayOfWeek.Sunday,
            DayOfWeek.Monday,
            DayOfWeek.Tuesday,
            DayOfWeek.Wednesday,
            DayOfWeek.Thursday,
            DayOfWeek.Friday,
            DayOfWeek.Saturday
        };

        for (int i = 0; i < values.Length; ++i)
        {
            string actual = info.GetDayName(values[i]);
            if (actual != expected[i])
            {
                TestLibrary.TestFramework.LogError(errorno, "GetDayName returns wrong value");
                TestLibrary.TestFramework.LogInformation("WARNING[LOCAL VARIABLES] values[i] = " + values[i] + ", expected[i] = " + expected[i] + ", actual = " + actual);
                retval = false;
            }
        }

        return retval;
    }