using System; namespace DataGridWithTreeMesu { /// <summary> /// Summary description for DateTime. /// </summary> public class MyDateTime { public MyDateTime() { // // TODO: Add constructor logic here // } /// <summary> /// JulianToGregorian /// </summary> /// <PARAM name="strGregDate">string</PARAM> /// <PARAM name="strFormat">string</PARAM> public string JulianToGregorian(string strGregDate, string strFormat) { DateTime dtStart; DateTime dtTrms; int iDays; int iYear; string strDate; int iPos; Array arParams = null; strFormat = strFormat.ToUpper(); arParams = strGregDate.Split('.'); iYear = Convert.ToInt32((arParams.GetValue(0)).ToString()); iDays = Convert.ToInt32((arParams.GetValue(1)).ToString()); dtStart = new DateTime(iYear, 1, 1); dtTrms = dtStart.AddDays(iDays - 1); strDate = dtTrms.ToString(); iPos = strDate.IndexOf(' '); strDate = strDate.Substring(0, iPos); strDate = ChangeDateFormat(strDate, strFormat); return strDate; } /// <summary> /// ChangeDateFormat /// </summary> /// <PARAM name="strDate">string</PARAM> /// <PARAM name="strFormat">string</PARAM> public string ChangeDateFormat(string strDate, string strFormat) { DateTime dateToInsert; try { dateToInsert = DateTime.Parse(strDate); } catch { dateToInsert = DateTime.MinValue; } strFormat = strFormat.ToUpper(); if(strFormat.StartsWith("MM") && strFormat.IndexOf("YYYY") != -1) strDate = dateToInsert.ToString("MM/dd/yyyy"); else if(strFormat.StartsWith("MM") && strFormat.IndexOf("YY") != -1) strDate = dateToInsert.ToString("MM/dd/yy"); else if(strFormat.StartsWith("DD") && strFormat.IndexOf("YYYY") != -1) strDate = dateToInsert.ToString("dd/MM/yyyy"); else if(strFormat.StartsWith("DD") && strFormat.IndexOf("YY") != -1) strDate = dateToInsert.ToString("dd/MM/yy"); return strDate; } } }
By viewing downloads associated with this article you agree to the Terms of use and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.
This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)
Old Japanese Man Creates Amazing Art Using Excel (Wait, Excel?)