Esempio n. 1
0
 public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
 {
     if (value is DateTime)
     {
         return(PersianDateTimeConverter.MiladiToShamsi((DateTime)value));
     }
     else if (value is string)
     {
         return(PersianDateTime.Parse((string)value));
     }
     else if (value is long)
     {
         return(PersianDateTime.FromInt64((long)value));
     }
     throw new ArgumentException("Parameter is not of type PersinaDateTime.", "obj");
 }
Esempio n. 2
0
        public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
        {
            var p = (PersianDateTime)value;

            if (destinationType == typeof(DateTime))
            {
                return(PersianDateTimeConverter.ShamsiToMiladi(p));
            }
            else if (destinationType == typeof(string))
            {
                return(p.ToString());
            }
            else if (destinationType == typeof(long))
            {
                return(p.ToInt64());
            }
            throw new ArgumentException("Type are not compatible");
        }
Esempio n. 3
0
 public PersianDateTime(DateTime d)
     : this(PersianDateTimeConverter.MiladiToShamsi(d))
 {
 }