示例#1
0
        public string GetString(string format)
        {
            string ret = format;

            int[] timeStamp = GetTimeStamp(_t);
            int   weekday   = this.GetWeekday();

            if (9999 < timeStamp[0])
            {
                timeStamp[0] = 9999;

                timeStamp[1] = 99;
                timeStamp[2] = 99;
                timeStamp[3] = 99;
                timeStamp[4] = 99;
                timeStamp[5] = 99;
                weekday      = 0;
            }
            ret = ret.Replace("Y", StringTools.ZPad(timeStamp[0], 4));
            ret = ret.Replace("M", StringTools.ZPad(timeStamp[1], 2));
            ret = ret.Replace("D", StringTools.ZPad(timeStamp[2], 2));
            ret = ret.Replace("h", StringTools.ZPad(timeStamp[3], 2));
            ret = ret.Replace("m", StringTools.ZPad(timeStamp[4], 2));
            ret = ret.Replace("s", StringTools.ZPad(timeStamp[5], 2));
            ret = ret.Replace("W", GetJWeekday(weekday));

            return(ret);
        }
示例#2
0
        public static string GetString(DateTime dt, string format)
        {
            string ret = format;

            ret = ret.Replace("Y", StringTools.ZPad(dt.Year, 4));
            ret = ret.Replace("M", StringTools.ZPad(dt.Month, 2));
            ret = ret.Replace("D", StringTools.ZPad(dt.Day, 2));
            ret = ret.Replace("h", StringTools.ZPad(dt.Hour, 2));
            ret = ret.Replace("m", StringTools.ZPad(dt.Minute, 2));
            ret = ret.Replace("s", StringTools.ZPad(dt.Second, 2));

            return(ret);
        }