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


C# PersianCalendar.GetHour方法代码示例

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


在下文中一共展示了PersianCalendar.GetHour方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ConvertToIranTimeString

        public string ConvertToIranTimeString(DateTime Date)
        {
            //string zoneId = "Iran Standard Time";
            //TimeZoneInfo tzi = TimeZoneInfo.FindSystemTimeZoneById(zoneId);
            //DateTime result = TimeZoneInfo.ConvertTimeFromUtc(Date, tzi);

            Date = Date.AddMinutes(-150);

            PersianCalendar pc = new PersianCalendar();
            string year = pc.GetYear(Date).ToString();
            string Month = pc.GetMonth(Date).ToString();
            string Day = pc.GetDayOfMonth(Date).ToString();
            string Hour = pc.GetHour(Date).ToString();
            string Minute = pc.GetMinute(Date).ToString();

            if (Month.Length == 1)
            {
                Month = "0" + Month;
            }
            if (Day.Length == 1)
            {
                Day = "0" + Day;
            }
            if (Hour.Length == 1)
            {
                Hour = "0" + Hour;
            }
            if (Minute.Length == 1)
            {
                Minute = "0" + Minute;
            }

            return year + "/" + Month + "/" + Day + " " + Hour + ":" + Minute;
        }
开发者ID:farhad85,项目名称:Iranegan,代码行数:34,代码来源:Time.cs

示例2: setTime

 public string setTime()
 {
     PersianCalendar pdate = new PersianCalendar();
     DateTime nT = new DateTime();
     nT = DateTime.Now;
     string time = "";
     time = pdate.GetHour(nT) + ":" + pdate.GetMinute(nT);
     return time;
 }
开发者ID:saeedehsaneei,项目名称:educationDegree,代码行数:9,代码来源:Main.Master.cs

示例3: ConvertToPersianDatetime

        public static DateTime ConvertToPersianDatetime(DateTime datetime)
        {
            var per = new PersianCalendar();

            var year = per.GetYear(datetime);
            var month = per.GetMonth(datetime);
            var day = per.GetDayOfMonth(datetime);
            var hour = per.GetHour(datetime);
            var minute = per.GetMinute(datetime);

            return new DateTime(year, month, day, hour, minute, 0);
        }
开发者ID:Chitva,项目名称:Ganjine,代码行数:12,代码来源:CommonMethods.cs

示例4: getNewNameForMp4

 private string getNewNameForMp4(string path)
 {
     try
     {
         FileInfo fi = new FileInfo(path);
         MediaInfo mi = new MediaInfo();
         mi.Open(path);
         string[] dataLines = mi.Inform().Split('\n');
         foreach (string line in dataLines)
         {
             if (line.StartsWith("Encoded date"))
             {
                 // parse `encoded date` tag:
                 // >Encoded date                             : UTC 2014-07-29 15:21:29
                 string newLine = line.Substring(line.IndexOf(':') + 1);    // > UTC 2014-07-29 15:21:29
                 newLine = newLine.Replace("UTC", "");                       // >  2014-07-29 15:21:29
                 newLine = newLine.Trim();                                   // >2014-07-29 15:21:29
                 //newLine = newLine.Replace(':', '-');                      // >2014-07-29 15-21-29
                 DateTime dt = DateTime.Parse(newLine);
                 PersianCalendar pc = new PersianCalendar();
                 StringBuilder result = new StringBuilder();
                 result.Append(pc.GetYear(dt));
                 result.Append('_');
                 result.Append(pc.GetMonth(dt));
                 return String.Format(
                     "{0}_{1,2:D2}_{2,2:D2} - {3:D2}_{4:D2}_{5:D2}{6}",
                     pc.GetYear(dt),
                     pc.GetMonth(dt),
                     pc.GetDayOfMonth(dt),
                     pc.GetHour(dt),
                     pc.GetMinute(dt),
                     pc.GetSecond(dt),
                     fi.Extension
                 );
             }
         }
         return "";
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         return "";
     }
 }
开发者ID:alimzadeh,项目名称:FixCameraFileName,代码行数:44,代码来源:FrmMain.cs

示例5: getNewNameForJpg

        private string getNewNameForJpg(string path)
        {
            try
            {
                FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read);
                Image myImage = Image.FromStream(fs, false, false);
                PropertyItem propItem = myImage.GetPropertyItem(36867);
                string dateTaken = Encoding.UTF8.GetString(propItem.Value);
                fs.Close();
                string[] dateTakenParts = dateTaken.Split(' ');
                dateTakenParts[0] = dateTakenParts[0].Replace(':', '-');
                DateTime dt = DateTime.Parse(dateTakenParts[0] + " " + dateTakenParts[1]);

                PersianCalendar pc = new PersianCalendar();
                StringBuilder result = new StringBuilder();
                result.Append(pc.GetYear(dt));
                result.Append('_');
                result.Append(pc.GetMonth(dt));
                return String.Format(
                    "{0}_{1,2:D2}_{2,2:D2} - {3:D2}_{4:D2}_{5:D2}{6}",
                    pc.GetYear(dt),
                    pc.GetMonth(dt),
                    pc.GetDayOfMonth(dt),
                    pc.GetHour(dt),
                    pc.GetMinute(dt),
                    pc.GetSecond(dt),
                    new FileInfo(path).Extension
                );
            }
            catch
            {
                return "";
            }
        }
开发者ID:alimzadeh,项目名称:FixCameraFileName,代码行数:34,代码来源:FrmMain.cs

示例6: Parse

        public static PersianDateTime Parse(DateTime dateTime)
        {
            var cal = new PersianCalendar();
            var result = new PersianDateTime
            {
                Year = cal.GetYear(dateTime),
                Month = cal.GetMonth(dateTime),
                Day = cal.GetDayOfMonth(dateTime),
                Hour = cal.GetHour(dateTime),
                Minute = cal.GetMinute(dateTime),
                Second = cal.GetSecond(dateTime)
            };

            return result;
        }
开发者ID:hamidhaghighatkhah,项目名称:WebApi-Routes,代码行数:15,代码来源:DateHelper.cs

示例7: PersianDateTime

 public PersianDateTime()
 {
     var dateTime = DateTime.Now;
     var calendar = new PersianCalendar();
     Year = calendar.GetYear(dateTime);
     Month = calendar.GetMonth(dateTime);
     Day = calendar.GetDayOfMonth(dateTime);
     Hour = calendar.GetHour(dateTime);
     Minute = calendar.GetMinute(dateTime);
     Second = calendar.GetSecond(dateTime);
 }
开发者ID:hamidhaghighatkhah,项目名称:WebApi-Routes,代码行数:11,代码来源:DateHelper.cs


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