Exemplo 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");
 }
Exemplo 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");
        }
Exemplo n.º 3
0
 public PersianDateTime(DateTime d)
     : this(PersianDateTimeConverter.MiladiToShamsi(d))
 {
 }