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.ThaiBuddhistEra;
13 
14 // import hunt.time.temporal.ChronoField;
15 
16 // import hunt.time.Exceptions;
17 // import hunt.time.format.DateTimeFormatterBuilder;
18 // import hunt.time.format.TextStyle;
19 // // import hunt.time.util.Locale;
20 
21 // /**
22 //  * An era _in the Thai Buddhist calendar system.
23 //  * !(p)
24 //  * The Thai Buddhist calendar system has two eras.
25 //  * The current era, for years from 1 onwards, is known as the 'Buddhist' era.
26 //  * All previous years, zero or earlier _in the proleptic count or one and greater
27 //  * _in the year-of-era count, are part of the 'Before Buddhist' era.
28 //  *
29 //  * <table class="striped" style="text-align:left">
30 //  * <caption style="display:none">Buddhist years and eras</caption>
31 //  * !(thead)
32 //  * !(tr)
33 //  * <th scope="col">year-of-era</th>
34 //  * <th scope="col">era</th>
35 //  * <th scope="col">proleptic-year</th>
36 //  * <th scope="col">ISO proleptic-year</th>
37 //  * </tr>
38 //  * </thead>
39 //  * !(tbody)
40 //  * !(tr)
41 //  * !(td)2</td>!(td)BE</td><th scope="row">2</th>!(td)-542</td>
42 //  * </tr>
43 //  * !(tr)
44 //  * !(td)1</td>!(td)BE</td><th scope="row">1</th>!(td)-543</td>
45 //  * </tr>
46 //  * !(tr)
47 //  * !(td)1</td>!(td)BEFORE_BE</td><th scope="row">0</th>!(td)-544</td>
48 //  * </tr>
49 //  * !(tr)
50 //  * !(td)2</td>!(td)BEFORE_BE</td><th scope="row">-1</th>!(td)-545</td>
51 //  * </tr>
52 //  * </tbody>
53 //  * </table>
54 //  * !(p)
55 //  * !(b)Do not use {@code ordinal()} to obtain the numeric representation of {@code ThaiBuddhistEra}.
56 //  * Use {@code getValue()} instead.</b>
57 //  *
58 //  * @implSpec
59 //  * This is an immutable and thread-safe enum.
60 //  *
61 //  * @since 1.8
62 //  */
63 // public class ThaiBuddhistEra : Era {
64 
65 //     /**
66 //      * The singleton instance for the era before the current one, 'Before Buddhist Era',
67 //      * which has the numeric value 0.
68 //      */
69 //     ThaiBuddhistEra BEFORE_BE = new ThaiBuddhistEra();
70 //     /**
71 //      * The singleton instance for the current era, 'Buddhist Era',
72 //      * which has the numeric value 1.
73 //      */
74 //     ThaiBuddhistEra BE = new ThaiBuddhistEra();
75 
76 //     //-----------------------------------------------------------------------
77 //     /**
78 //      * Obtains an instance of {@code ThaiBuddhistEra} from an {@code int} value.
79 //      * !(p)
80 //      * {@code ThaiBuddhistEra} is an enum representing the Thai Buddhist eras of BEFORE_BE/BE.
81 //      * This factory allows the enum to be obtained from the {@code int} value.
82 //      *
83 //      * @param thaiBuddhistEra  the era to represent, from 0 to 1
84 //      * @return the BuddhistEra singleton, never null
85 //      * @throws DateTimeException if the era is invalid
86 //      */
87 //     public static ThaiBuddhistEra of(int thaiBuddhistEra) {
88 //         switch (thaiBuddhistEra) {
89 //             case 0:
90 //                 return BEFORE_BE;
91 //             case 1:
92 //                 return BE;
93 //             default:
94 //                 throw new DateTimeException("Invalid era: " ~ thaiBuddhistEra);
95 //         }
96 //     }
97 
98 //     //-----------------------------------------------------------------------
99 //     /**
100 //      * Gets the numeric era {@code int} value.
101 //      * !(p)
102 //      * The era BEFORE_BE has the value 0, while the era BE has the value 1.
103 //      *
104 //      * @return the era value, from 0 (BEFORE_BE) to 1 (BE)
105 //      */
106 //     override
107 //     public int getValue() {
108 //         return ordinal();
109 //     }
110 
111 //     /**
112 //      * {@inheritDoc}
113 //      *
114 //      * @param style {@inheritDoc}
115 //      * @param locale {@inheritDoc}
116 //      */
117 //     override
118 //     public string getDisplayName(TextStyle style, Locale locale) {
119 //         return new DateTimeFormatterBuilder()
120 //             .appendText(ERA, style)
121 //             .toFormatter(locale)
122 //             .withChronology(ThaiBuddhistChronology.INSTANCE)
123 //             .format(this == BE ? ThaiBuddhistDate.of(1, 1, 1) : ThaiBuddhistDate.of(0, 1, 1));
124 //     }
125 
126 // }