Exemple #1
0
        private static IEnumerable <TmStmp> GetTmStmpDicntrKeys()
        {
            bool[] boolValues = new bool[] { false, true };

            TimeStamp?[] tmStmpValues = new TimeStamp?[]
            {
                null,
                TimeStamp.Minutes,
                TimeStamp.Seconds,
                TimeStamp.ShortMillis,
                TimeStamp.FullMillis
            };

            foreach (bool hasDate in boolValues)
            {
                foreach (TimeStamp?tmStmp in tmStmpValues)
                {
                    foreach (bool hasTimeZone in boolValues)
                    {
                        foreach (bool isForFileName in boolValues)
                        {
                            TmStmp value = GetTmStmp(
                                hasDate,
                                tmStmp,
                                hasTimeZone,
                                isForFileName);

                            yield return(value);
                        }
                    }
                }
            }
        }
Exemple #2
0
        public string TmStmp(
            DateTime?dateTime,
            TmStmp tmStmp)
        {
            dateTime = dateTime ?? DateTime.Now;
            string tmStmpTpl = TmStmpsDictnr[tmStmp];

            string tmStmpStr = dateTime.Value.ToString(
                tmStmpTpl);

            return(tmStmpStr);
        }
Exemple #3
0
        private static TmStmp GetTmStmp(
            bool hasDate,
            TimeStamp?tmStmp,
            bool hasTimeZone,
            bool isForFileName)
        {
            TmStmp value = new TmStmp(
                hasDate,
                tmStmp,
                hasTimeZone,
                isForFileName);

            return(value);
        }
Exemple #4
0
        public string TmStmp(
            bool hasDate,
            TimeStamp?tmStmp   = TimeStamp.Minutes,
            bool hasTimeZone   = false,
            bool isForFileName = false)
        {
            TmStmp key = GetTmStmp(
                hasDate,
                tmStmp,
                hasTimeZone,
                isForFileName);

            string tmStmpStr = TmStmpsDictnr[key];

            return(tmStmpStr);
        }
Exemple #5
0
        private static string GetTmStmpCore(TmStmp tmStmp)
        {
            StringBuilder sb = new StringBuilder();

            if (tmStmp.HasDate)
            {
                sb.Append("yyyy-MM-dd");
            }

            if (tmStmp.TimeStamp.HasValue)
            {
                sb.Append(" HH:mm");
                var tmStmpVal = tmStmp.TimeStamp.Value;

                if (tmStmpVal >= TimeStamp.Seconds)
                {
                    sb.Append(":ss");
                }

                if (tmStmpVal >= TimeStamp.ShortMillis)
                {
                    sb.Append(".FFF");
                }

                if (tmStmpVal >= TimeStamp.FullMillis)
                {
                    sb.Append("FFFF");
                }
            }

            if (tmStmp.HasTimeZone)
            {
                sb.Append("K");
            }

            string tmStmpStr = sb.ToString();

            if (tmStmp.IsForFileName)
            {
                tmStmpStr = tmStmpStr.Replace(":", string.Empty);
            }

            return(tmStmpStr);
        }
Exemple #6
0
        public string TmStmp(TmStmp tmStmp)
        {
            string tmStmpStr = TmStmpsDictnr[tmStmp];

            return(tmStmpStr);
        }