コード例 #1
0
        public override object Convert(object value)
        {
            if (value == null)
            {
                return(value);
            }
            string returnValue = value.ToString();

            Tracer.TraceInformation("formatdate-from {0} / {1}", DateType, returnValue);
            if (DateType.Equals(DateType.FileTimeUTC))
            {
                returnValue = DateTime.FromFileTimeUtc(long.Parse(value.ToString())).ToString(ToFormat);
                return(returnValue);
            }
            if (DateType.Equals(DateType.BestGuess))
            {
                returnValue = DateTime.Parse(value.ToString(), CultureInfo.InvariantCulture).ToString(ToFormat);
                return(returnValue);
            }
            if (DateType.Equals(DateType.DateTime))
            {
                returnValue = DateTime.ParseExact(value.ToString(), FromFormat, CultureInfo.InvariantCulture).ToString(ToFormat);
                return(returnValue);
            }
            return(returnValue);
        }
コード例 #2
0
ファイル: Transforms.cs プロジェクト: guoyu07/mare-4
        public override object Convert(object value)
        {
            if (value == null)
            {
                return(value);
            }
            string returnValue = value as string;

            if (DateType.Equals(DateType.FileTimeUTC))
            {
                returnValue = DateTime.FromFileTimeUtc(long.Parse(value as string)).ToString(ToFormat);
                return(returnValue);
            }
            if (DateType.Equals(DateType.BestGuess))
            {
                returnValue = DateTime.Parse(value as string, CultureInfo.InvariantCulture).ToString(ToFormat);
                return(returnValue);
            }
            if (DateType.Equals(DateType.DateTime))
            {
                returnValue = DateTime.ParseExact(value as string, FromFormat, CultureInfo.InvariantCulture).ToString(ToFormat);
                return(returnValue);
            }
            return(returnValue);
        }
コード例 #3
0
ファイル: Calendar.cs プロジェクト: jmacattack22/DadXO
    public string getDate(DateType type)
    {
        if (type.Equals(DateType.fullLong))
        {
            return(convertWeekToString(week) + " week of " + monthsInYear [month - 1] + ", " + year);
        }
        else if (type.Equals(DateType.fullShort))
        {
            return(week + "/" + month + "/" + year);
        }
        else if (type.Equals(DateType.weekAndMonth))
        {
            return(convertWeekToString(week) + " week of " + monthsInYear [month - 1]);
        }
        else if (type.Equals(DateType.weekFull))
        {
            return(convertWeekToString(week));
        }
        else if (type.Equals(DateType.weekShort))
        {
            return(week.ToString());
        }
        else if (type.Equals(DateType.monthFull))
        {
            return(monthsInYear [month - 1]);
        }
        else if (type.Equals(DateType.monthShort))
        {
            return(month.ToString());
        }
        else if (type.Equals(DateType.year))
        {
            return(year.ToString());
        }

        return("");
    }