1 
2  /*
3  * hunt-time: A time library for D programming language.
4  *
5  * Copyright (C) 2015-2018 HuntLabs
6  *
7  * Website: https://www.huntlabs.net/
8  *
9  * Licensed under the Apache-2.0 License.
10  *
11  */
12 
13 module hunt.time.chrono.HijrahEra;
14 
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.temporal.ChronoField;
21 // import hunt.time.temporal.TemporalField;
22 // import hunt.time.Exceptions;
23 // import hunt.time.temporal.ValueRange;
24 // // import hunt.time.util.Locale;
25 
26 // /**
27 //  * An era _in the Hijrah calendar system.
28 //  * !(p)
29 //  * The Hijrah calendar system has only one era covering the
30 //  * proleptic years greater than zero.
31 //  * !(p)
32 //  * !(b)Do not use {@code ordinal()} to obtain the numeric representation of {@code HijrahEra}.
33 //  * Use {@code getValue()} instead.</b>
34 //  *
35 //  * @implSpec
36 //  * This is an immutable and thread-safe enum.
37 //  *
38 //  * @since 1.8
39 //  */
40 // public class HijrahEra : Era {
41 
42 //     /**
43 //      * The singleton instance for the current era, 'Anno Hegirae',
44 //      * which has the numeric value 1.
45 //      */
46 //     HijrahEra AH = new HijrahEra();
47 
48 //     //-----------------------------------------------------------------------
49 //     /**
50 //      * Obtains an instance of {@code HijrahEra} from an {@code int} value.
51 //      * !(p)
52 //      * The current era, which is the only accepted value, has the value 1
53 //      *
54 //      * @param hijrahEra  the era to represent, only 1 supported
55 //      * @return the HijrahEra.AH singleton, not null
56 //      * @throws DateTimeException if the value is invalid
57 //      */
58 //     public static HijrahEra of(int hijrahEra) {
59 //         if (hijrahEra == 1 ) {
60 //             return AH;
61 //         } else {
62 //             throw new DateTimeException("Invalid era: " ~ hijrahEra);
63 //         }
64 //     }
65 
66 //     //-----------------------------------------------------------------------
67 //     /**
68 //      * Gets the numeric era {@code int} value.
69 //      * !(p)
70 //      * The era AH has the value 1.
71 //      *
72 //      * @return the era value, 1 (AH)
73 //      */
74 //     override
75 //     public int getValue() {
76 //         return 1;
77 //     }
78 
79 //     //-----------------------------------------------------------------------
80 //     /**
81 //      * Gets the range of valid values for the specified field.
82 //      * !(p)
83 //      * The range object expresses the minimum and maximum valid values for a field.
84 //      * This era is used to enhance the accuracy of the returned range.
85 //      * If it is not possible to return the range, because the field is not supported
86 //      * or for some other reason, an exception is thrown.
87 //      * !(p)
88 //      * If the field is a {@link ChronoField} then the query is implemented here.
89 //      * The {@code ERA} field returns the range.
90 //      * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}.
91 //      * !(p)
92 //      * If the field is not a {@code ChronoField}, then the result of this method
93 //      * is obtained by invoking {@code TemporalField.rangeRefinedBy(TemporalAccessor)}
94 //      * passing {@code this} as the argument.
95 //      * Whether the range can be obtained is determined by the field.
96 //      * !(p)
97 //      * The {@code ERA} field returns a range for the one valid Hijrah era.
98 //      *
99 //      * @param field  the field to query the range for, not null
100 //      * @return the range of valid values for the field, not null
101 //      * @throws DateTimeException if the range for the field cannot be obtained
102 //      * @throws UnsupportedTemporalTypeException if the unit is not supported
103 //      */
104 //     override  // override as super would return range from 0 to 1
105 //     public ValueRange range(TemporalField field) {
106 //         if (field == ERA) {
107 //             return ValueRange.of(1, 1);
108 //         }
109 //         return /* Era. */super.range(field);
110 //     }
111 
112 //     /**
113 //      * {@inheritDoc}
114 //      *
115 //      * @param style {@inheritDoc}
116 //      * @param locale {@inheritDoc}
117 //      */
118 //     override
119 //     public string getDisplayName(TextStyle style, Locale locale) {
120 //         return new DateTimeFormatterBuilder()
121 //             .appendText(ERA, style)
122 //             .toFormatter(locale)
123 //             .withChronology(HijrahChronology.INSTANCE)
124 //             .format(HijrahDate.now());
125 //     }
126 // }