main
1using System;
2using gorilla.utility;
3
4namespace solidware.financials.service.domain
5{
6 public class Date : IComparable<Date>
7 {
8 long ticks;
9 static public readonly Date First = new Date(DateTime.MinValue);
10 static public readonly Date Last = new Date(DateTime.MaxValue);
11
12 Date(DateTime date)
13 {
14 ticks = date.Date.Ticks;
15 }
16
17 static public implicit operator Date(DateTime raw)
18 {
19 return new Date(raw);
20 }
21
22 public bool Equals(Date other)
23 {
24 if (ReferenceEquals(null, other)) return false;
25 if (ReferenceEquals(this, other)) return true;
26 return other.ticks == ticks;
27 }
28
29 public int CompareTo(Date other)
30 {
31 return to_date_time().CompareTo(new DateTime(other.ticks));
32 }
33
34 public override bool Equals(object obj)
35 {
36 if (ReferenceEquals(null, obj)) return false;
37 if (ReferenceEquals(this, obj)) return true;
38 if (obj.GetType() != typeof (Date)) return false;
39 return Equals((Date) obj);
40 }
41
42 public override int GetHashCode()
43 {
44 return ticks.GetHashCode();
45 }
46
47 public override string ToString()
48 {
49 return "{0}".format(to_date_time());
50 }
51
52 public DateTime to_date_time()
53 {
54 return new DateTime(ticks);
55 }
56 }
57}