当前位置: 首页>>代码示例>>C#>>正文


C# Globalization.DateTimeFormatInfo类代码示例

本文整理汇总了C#中System.Globalization.DateTimeFormatInfo的典型用法代码示例。如果您正苦于以下问题:C# DateTimeFormatInfo类的具体用法?C# DateTimeFormatInfo怎么用?C# DateTimeFormatInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DateTimeFormatInfo类属于System.Globalization命名空间,在下文中一共展示了DateTimeFormatInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Clone

        public void Clone(DateTimeFormatInfo format)
        {
            DateTimeFormatInfo clone = (DateTimeFormatInfo)format.Clone();
            Assert.NotSame(format, clone);

            Assert.False(clone.IsReadOnly);
            Assert.Equal(format.AbbreviatedDayNames, clone.AbbreviatedDayNames);
            Assert.Equal(format.AbbreviatedMonthGenitiveNames, clone.AbbreviatedMonthGenitiveNames);
            Assert.Equal(format.AbbreviatedMonthNames, clone.AbbreviatedMonthNames);
            Assert.Equal(format.DayNames, clone.DayNames);
            Assert.Equal(format.MonthGenitiveNames, clone.MonthGenitiveNames);
            Assert.Equal(format.MonthNames, clone.MonthNames);
            Assert.Equal(format.ShortestDayNames, clone.ShortestDayNames);

            Assert.Equal(format.AMDesignator, clone.AMDesignator);
            Assert.Equal(format.FullDateTimePattern, clone.FullDateTimePattern);
            Assert.Equal(format.LongDatePattern, clone.LongDatePattern);
            Assert.Equal(format.LongTimePattern, clone.LongTimePattern);
            Assert.Equal(format.MonthDayPattern, clone.MonthDayPattern);
            Assert.Equal(format.PMDesignator, clone.PMDesignator);
            Assert.Equal(format.RFC1123Pattern, clone.RFC1123Pattern);
            Assert.Equal(format.ShortDatePattern, clone.ShortDatePattern);
            Assert.Equal(format.ShortTimePattern, clone.ShortTimePattern);
            Assert.Equal(format.SortableDateTimePattern, clone.SortableDateTimePattern);
            Assert.Equal(format.UniversalSortableDateTimePattern, clone.UniversalSortableDateTimePattern);
            Assert.Equal(format.YearMonthPattern, clone.YearMonthPattern);
            Assert.Equal(format.CalendarWeekRule, clone.CalendarWeekRule);
            Assert.Equal(format.FirstDayOfWeek, clone.FirstDayOfWeek);
        }
开发者ID:benpye,项目名称:corefx,代码行数:29,代码来源:DateTimeFormatInfoClone.cs

示例2: SetPersianDateTimeFormatInfo

        public static void SetPersianDateTimeFormatInfo(DateTimeFormatInfo persianDateTimeFormatInfo)
        {
            persianDateTimeFormatInfo.MonthNames = new[] { "فروردین", "اردیبهشت", "خرداد", "تیر", "مرداد", "شهریور", "مهر", "آبان", "آذر", "دی", "بهمن", "اسفند", "" };
            persianDateTimeFormatInfo.MonthGenitiveNames = persianDateTimeFormatInfo.MonthNames;
            persianDateTimeFormatInfo.AbbreviatedMonthNames = persianDateTimeFormatInfo.MonthNames;
            persianDateTimeFormatInfo.AbbreviatedMonthGenitiveNames = persianDateTimeFormatInfo.MonthNames;

            persianDateTimeFormatInfo.DayNames = new[] { "یکشنبه", "دوشنبه", "ﺳﻪشنبه", "چهارشنبه", "پنجشنبه", "جمعه", "شنبه" };
            persianDateTimeFormatInfo.AbbreviatedDayNames = new[] { "ی", "د", "س", "چ", "پ", "ج", "ش" };
            persianDateTimeFormatInfo.ShortestDayNames = persianDateTimeFormatInfo.AbbreviatedDayNames;
            persianDateTimeFormatInfo.FirstDayOfWeek = DayOfWeek.Saturday;

            persianDateTimeFormatInfo.AMDesignator = "ق.ظ";
            persianDateTimeFormatInfo.PMDesignator = "ب.ظ";

            persianDateTimeFormatInfo.DateSeparator = "/";
            persianDateTimeFormatInfo.TimeSeparator = ":";

            persianDateTimeFormatInfo.FullDateTimePattern = "tt hh:mm:ss yyyy mmmm dd dddd";
            persianDateTimeFormatInfo.YearMonthPattern = "yyyy, MMMM";
            persianDateTimeFormatInfo.MonthDayPattern = "dd MMMM";

            persianDateTimeFormatInfo.LongDatePattern = "dddd, dd MMMM,yyyy";
            persianDateTimeFormatInfo.ShortDatePattern = "yyyy/MM/dd";

            persianDateTimeFormatInfo.LongTimePattern = "hh:mm:ss tt";
            persianDateTimeFormatInfo.ShortTimePattern = "hh:mm tt";
        }
开发者ID:VegasoftTI,项目名称:Dnn.Platform,代码行数:28,代码来源:PersianController.cs

示例3: TestWritable

        public void TestWritable()
        {
            DateTimeFormatInfo info = new DateTimeFormatInfo();
            DateTimeFormatInfo actual = DateTimeFormatInfo.ReadOnly(info);

            Assert.True(actual.IsReadOnly);
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:7,代码来源:DateTimeFormatInfoReadOnly.cs

示例4: GetAutoPouring

        public IQueryable<AutoPouring> GetAutoPouring(string begTimes, string endTimes, string resin)
        {
            _apc.Configuration.ProxyCreationEnabled = false;
            DateTimeFormatInfo dtFormat = new System.Globalization.DateTimeFormatInfo();
            dtFormat.ShortDatePattern = "yyyy-MM-dd";
            DateTime begtime, endtime;
            begtime = Convert.ToDateTime(begTimes, dtFormat);//DateTime.Parse(begTimes);
            //begtime = DateTime.Parse(begTimes);
            endtime = Convert.ToDateTime(endTimes, dtFormat);//DateTime.Parse(endTimes);

               // Expression<Func<AutoPouring, bool>> sqlstr = a => (Convert.ToDateTime(a.SampleTimes.ToShortDateString(),dtFormat)>=begtime)
               //                  && (Convert.ToDateTime(a.SampleTimes.ToShortDateString(), dtFormat) <= endtime)
            //                 && (a.ResinNo.Contains(resin) || resin == null);

            ///ef6中使用DbFunctions解決日期比較問題,使用System.Data.Objects.SqlClient.SqlFunctions會報錯
            var query = from a in _apc.AutoPouring
                        where (DbFunctions.TruncateTime(a.SampleTimes)>=begtime || begtime==null)
                           && (DbFunctions.TruncateTime(a.SampleTimes)<=endtime|| endtime==null)
                           //&&   DbFunctions.DiffDays(a.SampleTimes,endtime)<=0  DbFunctions.
                           && (a.ResinNo.Contains(resin) || resin == null)
                        select a;
               return query;

            //Expression<Func<AutoPouring, bool>> theName = (a => a.SampleTimes.ToString("yyyy-MM-dd HH:mm:ss")> begTimes && a.ResinNo.Contains(resin));
            //var query = _apc.AutoPouring.Where(sqlstr.Compile()).AsQueryable();
        }
开发者ID:thomadzhou,项目名称:Projects,代码行数:26,代码来源:AutoPouringRepository.cs

示例5: InitPersianDateTimeFormat

 /// <summary>
 /// Represents a method that set persian option to specified instance CultureInfo
 /// </summary>
 /// <param name="dateTimeFormat">Represents an instance of DateTimeFormatInfo that persian option should be set to it.</param>
 public static void InitPersianDateTimeFormat(DateTimeFormatInfo info)
 {
     if (info == null)
         return;
     PersianCalendar calendar = new PersianCalendar();
     bool readOnly = (bool)dateTimeFormatInfoReadOnly.GetValue(info);
     if (readOnly)
     {
         dateTimeFormatInfoReadOnly.SetValue(info, false);
     }
     dateTimeFormatInfoCalendar.SetValue(info, calendar);
     //object obj2 = dateTimeFormatInfoCultureTableRecord.GetValue(info);
     //cultureTableRecordUseCurrentCalendar.Invoke(obj2, new object[] { calendarID.GetValue(calendar, null) });
     info.AbbreviatedDayNames = new string[] { "ی", "د", "س", "چ", "پ", "ج", "ش" };
     info.ShortestDayNames = new string[] { "ی", "د", "س", "چ", "پ", "ج", "ش" };
     info.DayNames = new string[] { "یکشنبه", "دوشنبه", "ﺳﻪشنبه", "چهارشنبه", "پنجشنبه", "جمعه", "شنبه" };
     info.AbbreviatedMonthNames = new string[] { "فروردین", "ارديبهشت", "خرداد", "تير", "مرداد", "شهریور", "مهر", "آبان", "آذر", "دی", "بهمن", "اسفند", "" };
     info.MonthNames = new string[] { "فروردین", "ارديبهشت", "خرداد", "تير", "مرداد", "شهریور", "مهر", "آبان", "آذر", "دی", "بهمن", "اسفند", "" };
     info.AMDesignator = "ق.ظ";
     info.PMDesignator = "ب.ظ";
     info.FirstDayOfWeek = DayOfWeek.Saturday;
     info.FullDateTimePattern = "yyyy MMMM dddd";
     info.LongDatePattern = "yyyy MMMM dddd, dd";
     info.ShortDatePattern = "yyyy/MM/dd";
     if (readOnly)
     {
         dateTimeFormatInfoReadOnly.SetValue(info, true);
     }
 }
开发者ID:Mahdi-K,项目名称:KCore,代码行数:33,代码来源:PersianCultureHelper.cs

示例6: Get

        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;
        }
开发者ID:catflinger,项目名称:bikes,代码行数:34,代码来源:ModelController.cs

示例7: PersianCultureInfo

 /// <summary>
 /// Initializes a new instance of the <see cref="PersianCultureInfo"/> class.
 /// </summary>
 public PersianCultureInfo()
     : base("fa-IR", false) {
     _calendar = new PersianCalendar();
     _format = PersianDateTimeFormatInfo.GetFormatInfo(_calendar);
     base.DateTimeFormat = _format;
     NumberFormat.DigitSubstitution = DigitShapes.NativeNational;
 }
开发者ID:kavand,项目名称:Kavand.Windows.Controls,代码行数:10,代码来源:PersianCultureInfo.cs

示例8: ReadOnly

        public void ReadOnly(DateTimeFormatInfo format, bool expected)
        {
            Assert.Equal(expected, format.IsReadOnly);

            DateTimeFormatInfo readOnlyFormat = DateTimeFormatInfo.ReadOnly(format);
            Assert.True(readOnlyFormat.IsReadOnly);
        }
开发者ID:benpye,项目名称:corefx,代码行数:7,代码来源:DateTimeFormatInfoReadOnly.cs

示例9: getItemFromDB

        public async void getItemFromDB()
        {
            this.allItems.Clear();
            try
            {
                var dp = App.conn;
                using (var statement = dp.Prepare(@"SELECT * FROM TaskItem"))
                {
                    while (SQLiteResult.ROW == statement.Step())
                    {
                        //do with pic
                        BitmapImage bimage = new BitmapImage();
                        StorageFile file = await StorageFile.GetFileFromPathAsync((string)statement[4]);
                        IRandomAccessStream instream = await file.OpenAsync(FileAccessMode.Read);
                        string boot = Windows.Storage.AccessCache.StorageApplicationPermissions.MostRecentlyUsedList.Add(file);
                        await bimage.SetSourceAsync(instream);
                        // 处理时间
                        DateTime dt;
                        DateTimeFormatInfo dtFormat = new DateTimeFormatInfo();
                        dtFormat.ShortDatePattern = "yyyy-MM-dd";
                        dt = Convert.ToDateTime((string)statement[3], dtFormat);
                        this.allItems.Add(new Models.TaskItem(statement[0].ToString(), statement[1].ToString(), (string)statement[2], bimage, dt, (string)statement[4], (string)statement[5], (string)statement[6]));
                    }
                }
            }
            catch
            {
                return;
            }


        }
开发者ID:Crazytinal,项目名称:xiancao_project,代码行数:32,代码来源:TaskItemViewModel.cs

示例10: AccountXml

 static AccountXml()
 {
     DateTimeFormatInfo = new DateTimeFormatInfo
     {
         ShortTimePattern = "yyyy-MM-dd HH:mm:ss"
     };
 }
开发者ID:johnmensen,项目名称:TradeSharp,代码行数:7,代码来源:DealXml.cs

示例11: Analysbtn_Click

        private void Analysbtn_Click(object sender, EventArgs e)
        {
            //we check the input number and if the number length = 14 will move to next step
            if (IDTB.Text.Length == 14)
            {
                //create object from DTFI to get month name
                DateTimeFormatInfo dtfi = new DateTimeFormatInfo();
                //create object from IDAnalyst  which contains all of process
                IDAnalyst id = new IDAnalyst();
                //convert id number from string in textBox to long
                long num = long.Parse(IDTB.Text);
                //set DateTimePicker "Date" to Date input to extract name of the day and month
                DTP.Value = new DateTime(int.Parse(id.GetBirthYear(num)), int.Parse(id.GetBirthMonth(num)), int.Parse(id.GetBirthDay(num)));
                //assign value of Day TextBox to day from IDAnalyst class and get a day from DateTimePicker
                Daytb.Text = id.GetBirthDay(num)+" : "+DTP.Value.DayOfWeek.ToString();
                //Get Month and using DTFI to get month name which we get from DateTimePicker
                Montb.Text = id.GetBirthMonth(num)+" : "+dtfi.GetMonthName(DTP.Value.Month);
                //Get Month Year
                Yeartb.Text = id.GetBirthYear(num);
                //Get Sex
                Sextb.Text = id.Sex(num);
                //Get Get Province Name
                provtb.Text = id.GetProvince(num);
                //Get Child number
                cid.Text = id.NumOfChild(num).ToString();

            }
        }
开发者ID:Ahmad-Magdy,项目名称:Egyptian-ID-Analyst,代码行数:28,代码来源:Form1.cs

示例12: openDateTimeAttributeFromNode

 public static DateTime openDateTimeAttributeFromNode(XmlNode node, string attributeName, string xmlNamespace)
 {
     XmlAttribute attr = node.Attributes[attributeName, xmlNamespace];
     DateTimeFormatInfo formatter = new DateTimeFormatInfo();
     formatter.FullDateTimePattern = PetriXmlHelper.DATE_FORMAT;
     return DateTime.ParseExact(attr.Value, PetriXmlHelper.DATE_FORMAT, formatter);
 }
开发者ID:davidbedok,项目名称:UBPNS,代码行数:7,代码来源:PetriXmlHelper.cs

示例13: VerificationHelper

 private void VerificationHelper(DateTimeFormatInfo expected, Object obj)
 {
     Assert.True(obj is DateTimeFormatInfo);
     DateTimeFormatInfo actual = obj as DateTimeFormatInfo;
     Assert.False(actual.IsReadOnly);
     IsEquals(actual.AbbreviatedDayNames, expected.AbbreviatedDayNames);
     IsEquals(actual.AbbreviatedMonthGenitiveNames, expected.AbbreviatedMonthGenitiveNames);
     IsEquals(actual.AbbreviatedMonthNames, expected.AbbreviatedMonthNames);
     IsEquals(actual.DayNames, expected.DayNames);
     IsEquals(actual.MonthGenitiveNames, expected.MonthGenitiveNames);
     IsEquals(actual.MonthNames, expected.MonthNames);
     IsEquals(actual.ShortestDayNames, expected.ShortestDayNames);
     IsEquals(actual.AMDesignator, expected.AMDesignator);
     //DateTimeFormatInfo.DateSeparator property has been removed
     IsEquals(actual.FullDateTimePattern, expected.FullDateTimePattern);
     IsEquals(actual.LongDatePattern, expected.LongDatePattern);
     IsEquals(actual.LongTimePattern, expected.LongTimePattern);
     IsEquals(actual.MonthDayPattern, expected.MonthDayPattern);
     IsEquals(actual.PMDesignator, expected.PMDesignator);
     IsEquals(actual.RFC1123Pattern, expected.RFC1123Pattern);
     IsEquals(actual.ShortDatePattern, expected.ShortDatePattern);
     IsEquals(actual.ShortTimePattern, expected.ShortTimePattern);
     IsEquals(actual.SortableDateTimePattern, expected.SortableDateTimePattern);
     //DateTimeFormatInfo.TimeSeparator property has been removed
     IsEquals(actual.UniversalSortableDateTimePattern, expected.UniversalSortableDateTimePattern);
     IsEquals(actual.YearMonthPattern, expected.YearMonthPattern);
     IsEquals(actual.CalendarWeekRule, expected.CalendarWeekRule);
     IsEquals(actual.FirstDayOfWeek, expected.FirstDayOfWeek);
 }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:29,代码来源:DateTimeFormatInfoClone.cs

示例14: AbbreviatedDayNames_Set

 public void AbbreviatedDayNames_Set()
 {
     string[] newAbbreviatedDayNames = new string[] { "1", "2", "3", "4", "5", "6", "7" };
     var format = new DateTimeFormatInfo();
     format.AbbreviatedDayNames = newAbbreviatedDayNames;
     Assert.Equal(newAbbreviatedDayNames, format.AbbreviatedDayNames);
 }
开发者ID:benpye,项目名称:corefx,代码行数:7,代码来源:DateTimeFormatInfoAbbreviatedDayNames.cs

示例15: MonthNames_Set

 public void MonthNames_Set()
 {
     string[] newMonthNames = new string[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "" };
     var format = new DateTimeFormatInfo();
     format.MonthNames = newMonthNames;
     Assert.Equal(newMonthNames, format.MonthNames);
 }
开发者ID:benpye,项目名称:corefx,代码行数:7,代码来源:DateTimeFormatInfoMonthNames.cs


注:本文中的System.Globalization.DateTimeFormatInfo类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。