示例#1
0
        public DateSpanUI()
        {
            InitializeComponent();
            this.Loaded += (s, e) =>UpdateValue(Value);
            txtYear.Text = DateTimeMessage._0Years.NiceToString().Formato("");
            txtMonth.Text = DateTimeMessage._0Month.NiceToString().Formato("");
            txtDay.Text = DateTimeMessage._0Days.NiceToString().Formato("");

            this.Day.ValueChanged += (s, e) => Value = new DateSpan(Value.Years, Value.Months, (int?)e.NewValue ?? 0);
            this.Month.ValueChanged += (s, e) => Value = new DateSpan(Value.Years, (int?)e.NewValue ?? 0, Value.Days);
            this.Year.ValueChanged += (s, e) => Value = new DateSpan((int?)e.NewValue ?? 0, Value.Months, Value.Days);
        }
示例#2
0
 private void UpdateValue(DateSpan ds)
 {
     Day.Value = ds.Days;
     Month.Value = ds.Months;
     Year.Value = ds.Years;
 }
 public static DateTime Add(this DateTime date, DateSpan dateSpan)
 {
     return(dateSpan.AddTo(date));
 }
 public static DateTime Add(this DateTime date, DateSpan dateSpan)
 {
     return dateSpan.AddTo(date);
 }
 public static DateSpan DateSpanTo(this DateTime min, DateTime max)
 {
     return(DateSpan.FromToDates(min, max));
 }