本文整理汇总了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;
}
示例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;
}
示例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);
}
示例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 "";
}
}
示例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 "";
}
}
示例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;
}
示例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);
}