Welcome to mirror list, hosted at ThFree Co, Russian Federation.

Time.cs « Common « Xamarin.PropertyEditing - github.com/xamarin/Xamarin.PropertyEditing.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 9905c40ad76d06c7e80a5a98616af321a50eb51e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using System;

namespace Xamarin.PropertyEditing.Common
{
	public class Time : IEquatable<Time>
	{
		private readonly DateTime dateTime;

		public DateTime DateTime {
			get {
				return this.dateTime;
			}
		}

		public Time (DateTime dateTime)
		{
			this.dateTime = dateTime;
		}

		public override bool Equals (object obj)
		{
			if (obj == null)
				return false;
			if ((obj is Time d))
				return Equals (d);
			else
				return false;
		}

		public bool Equals (Time other)
		{
			if (other == null)
				return false;
			return this.dateTime.Equals (other.DateTime);
		}

		public override int GetHashCode ()
		{
			var hashCode = 1861433795;
			unchecked {
				hashCode = hashCode * -1521134295 + this.dateTime.GetHashCode ();
			}
			return hashCode;
		}
		public override string ToString ()
		{
			return this.dateTime.ToLongTimeString ();
		}

		public static Time Parse(string value)
		{
			try {
				return new Time (DateTime.Parse (value));
			} catch (Exception) {
				return null;
			}
		}
	}
}