Example #1
0
            public string FormatNewsDate(Object date, bool isShort)
            {
                string result = "";

                string[] longdate;
                if (isShort)
                {
                    longdate = Fmt.Date(date.ToString()).Split('-');
                }
                else
                {
                    longdate = Fmt.LongDate(date).Split('-');
                }
                string day   = longdate[0];
                string month = longdate[1];
                string year  = longdate[2];

                if (day.StartsWith("0"))
                {
                    day = day.Remove(0, 1);
                }
                int intDay = day.ToInt();

                if (intDay < 11 || intDay > 13)
                {
                    if (day.EndsWith("1"))
                    {
                        day += "st";
                    }
                    else if (day.EndsWith("2"))
                    {
                        day += "nd";
                    }
                    else if (day.EndsWith("3"))
                    {
                        day += "rd";
                    }
                    else
                    {
                        day += "th";
                    }
                }
                else
                {
                    day += "th";
                }
                result = month + " " + day + ", " + year;
                return(result);
            }