1 /*
2  * hunt-time: A time library for D programming language.
3  *
4  * Copyright (C) 2015-2018 HuntLabs
5  *
6  * Website: https://www.huntlabs.net/
7  *
8  * Licensed under the Apache-2.0 License.
9  *
10  */
11 
12 module hunt.time.chrono.MinguoEra;
13 
14 import std.conv;
15 import hunt.time.temporal.ChronoField;
16 
17 import hunt.time.Exceptions;
18 // import hunt.time.format.DateTimeFormatterBuilder;
19 import hunt.time.format.TextStyle;
20 // import hunt.time.util.Locale;
21 import hunt.time.chrono.Era;
22 import hunt.time.chrono.ChronoLocalDateImpl;
23 import hunt.time.chrono.MinguoChronology;
24 
25 /**
26  * An era _in the Minguo calendar system.
27  * !(p)
28  * The Minguo calendar system has two eras.
29  * The current era, for years from 1 onwards, is known as the 'Republic of China' era.
30  * All previous years, zero or earlier _in the proleptic count or one and greater
31  * _in the year-of-era count, are part of the 'Before Republic of China' era.
32  *
33  * <table class="striped" style="text-align:left">
34  * <caption style="display:none">Minguo years and eras</caption>
35  * !(thead)
36  * !(tr)
37  * !(th)year-of-era</th>
38  * !(th)era</th>
39  * !(th)proleptic-year</th>
40  * !(th)ISO proleptic-year</th>
41  * </tr>
42  * </thead>
43  * !(tbody)
44  * !(tr)
45  * !(td)2</td>!(td)ROC</td><th scope="row">2</th>!(td)1913</td>
46  * </tr>
47  * !(tr)
48  * !(td)1</td>!(td)ROC</td><th scope="row">1</th>!(td)1912</td>
49  * </tr>
50  * !(tr)
51  * !(td)1</td>!(td)BEFORE_ROC</td><th scope="row">0</th>!(td)1911</td>
52  * </tr>
53  * !(tr)
54  * !(td)2</td>!(td)BEFORE_ROC</td><th scope="row">-1</th>!(td)1910</td>
55  * </tr>
56  * </tbody>
57  * </table>
58  * !(p)
59  * !(b)Do not use {@code ordinal()} to obtain the numeric representation of {@code MinguoEra}.
60  * Use {@code getValue()} instead.</b>
61  *
62  * @implSpec
63  * This is an immutable and thread-safe enum.
64  *
65  * @since 1.8
66  */
67 // public class MinguoEra : Era {
68 
69 //     /**
70 //      * The singleton instance for the era before the current one, 'Before Republic of China Era',
71 //      * which has the numeric value 0.
72 //      */
73 //     static MinguoEra BEFORE_ROC;
74 //     /**
75 //      * The singleton instance for the current era, 'Republic of China Era',
76 //      * which has the numeric value 1.
77 //      */
78 //     static MinguoEra ROC;
79 
80 //     static this()
81 //     {
82 //         BEFORE_ROC = new MinguoEra(0);
83 //         ROC = new MinguoEra(1);
84 //     }
85 
86 //     private int _ordinal;
87 
88 //     this(int ordinal)
89 //     {
90 //         _ordinal = ordinal;
91 //     }
92 //     //-----------------------------------------------------------------------
93 //     /**
94 //      * Obtains an instance of {@code MinguoEra} from an {@code int} value.
95 //      * !(p)
96 //      * {@code MinguoEra} is an enum representing the Minguo eras of BEFORE_ROC/ROC.
97 //      * This factory allows the enum to be obtained from the {@code int} value.
98 //      *
99 //      * @param minguoEra  the BEFORE_ROC/ROC value to represent, from 0 (BEFORE_ROC) to 1 (ROC)
100 //      * @return the era singleton, not null
101 //      * @throws DateTimeException if the value is invalid
102 //      */
103 //     public static MinguoEra of(int minguoEra) {
104 //         switch (minguoEra) {
105 //             case 0:
106 //                 return BEFORE_ROC;
107 //             case 1:
108 //                 return ROC;
109 //             default:
110 //                 throw new DateTimeException("Invalid era: " ~ minguoEra.to!string);
111 //         }
112 //     }
113 
114 //     //-----------------------------------------------------------------------
115 //     /**
116 //      * Gets the numeric era {@code int} value.
117 //      * !(p)
118 //      * The era BEFORE_ROC has the value 0, while the era ROC has the value 1.
119 //      *
120 //      * @return the era value, from 0 (BEFORE_ROC) to 1 (ROC)
121 //      */
122 //     override
123 //     public int getValue() {
124 //         return ordinal();
125 //     }
126 
127 //     /**
128 //      * {@inheritDoc}
129 //      *
130 //      * @param style {@inheritDoc}
131 //      * @param locale {@inheritDoc}
132 //      */
133 //     override
134 //     public string getDisplayName(TextStyle style, Locale locale) {
135 //         // return new DateTimeFormatterBuilder()
136 //         //     .appendText(ChronoField.ERA, style)
137 //         //     .toFormatter(locale)
138 //         //     // .withChronology(MinguoChronology.INSTANCE)
139 //         //     .format(this == ROC ? MinguoDate.of(1, 1, 1) : MinguoDate.of(0, 1, 1));
140 //         return null;
141 //     }
142 
143 //     int ordinal()
144 //     {
145 //         return _ordinal;
146 //     }
147 // }