~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to external/ngit/Sharpen/Sharpen/JavaCalendar.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
using System;
 
2
using System.Globalization;
 
3
 
 
4
namespace Sharpen
 
5
{
 
6
        public class JavaCalendar
 
7
        {
 
8
                public static int HOUR_OF_DAY = 0;
 
9
                public static int MINUTE = 1;
 
10
                public static int SECOND = 2;
 
11
                public static int MILLISECOND = 3;
 
12
                public static int DATE = 4;
 
13
                public static int YEAR = 5;
 
14
                public static int MONTH = 6;
 
15
                public static int WEEK_OF_YEAR = 7;
 
16
 
 
17
                DateTime Time;
 
18
 
 
19
                public JavaCalendar ()
 
20
                {
 
21
                        Time = DateTime.UtcNow;
 
22
                }
 
23
 
 
24
                public void Add (int type, int value)
 
25
                {
 
26
                        switch (type) {
 
27
                        case 0:
 
28
                                Time.AddHours (value);
 
29
                                break;
 
30
                        case 1:
 
31
                                Time.AddMinutes (value);
 
32
                                break;
 
33
                        case 2:
 
34
                                Time.AddSeconds (value);
 
35
                                break;
 
36
                        case 3:
 
37
                                Time.AddMilliseconds (value);
 
38
                                break;
 
39
                        case 5:
 
40
                                Time.AddYears (value);
 
41
                                break;
 
42
                        case 6:
 
43
                                Time.AddMonths (value);
 
44
                                break;
 
45
                        case 7:
 
46
                                Time.AddDays (7 * value);
 
47
                                break;
 
48
                        default:
 
49
                                throw new NotSupportedException ();
 
50
                        }
 
51
                }
 
52
 
 
53
                public JavaCalendar Clone ()
 
54
                {
 
55
                        return (JavaCalendar) MemberwiseClone ();
 
56
                }
 
57
 
 
58
                public DateTime GetTime ()
 
59
                {
 
60
                        return Time;
 
61
                }
 
62
 
 
63
                public void Set (int type, int value)
 
64
                {
 
65
                        switch (type) {
 
66
                        case 0:
 
67
                                Time.AddHours (value - Time.Hour);
 
68
                                break;
 
69
                        case 1:
 
70
                                Time.AddMinutes (value - Time.Minute);
 
71
                                break;
 
72
                        case 2:
 
73
                                Time.AddSeconds (value - Time.Second);
 
74
                                break;
 
75
                        case 3:
 
76
                                Time.AddMilliseconds (value - Time.Millisecond);
 
77
                                break;
 
78
                        case 5:
 
79
                                Time.AddYears (value - Time.Year);
 
80
                                break;
 
81
                        case 6:
 
82
                                Time.AddMonths (value - Time.Month);
 
83
                                break;
 
84
                        default:
 
85
                                throw new NotSupportedException ();
 
86
                        }
 
87
                }
 
88
 
 
89
                public void SetTimeInMillis (long milliseconds)
 
90
                {
 
91
                        Time = new DateTime (milliseconds * TimeSpan.TicksPerMillisecond);
 
92
                }
 
93
        }
 
94
 
 
95
        public class JavaGregorianCalendar : JavaCalendar
 
96
        {
 
97
                public JavaGregorianCalendar (TimeZoneInfo timezone, CultureInfo culture)
 
98
                {
 
99
                }
 
100
        }
 
101
}
 
102