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.temporal.ChronoField; 13 14 import hunt.time.temporal.ChronoUnit; 15 16 import hunt.time.DayOfWeek; 17 // import hunt.time.Instant; 18 import hunt.time.Year; 19 // import hunt.time.ZoneOffset; 20 // import hunt.time.chrono.ChronoLocalDate; 21 // import hunt.time.chrono.Chronology; 22 23 import hunt.time.temporal.TemporalField; 24 import hunt.time.temporal.TemporalUnit; 25 import hunt.time.temporal.ValueRange; 26 import hunt.time.temporal.TemporalAccessor; 27 import hunt.time.temporal.Temporal; 28 import hunt.time.format.ResolverStyle; 29 import hunt.time.util.Common; 30 31 import hunt.Exceptions; 32 import hunt.Enum; 33 import hunt.Long; 34 import hunt.collection; 35 import hunt.util.Comparator; 36 import hunt.util.Locale; 37 // import hunt.util.ResourceBundle; 38 // import sun.util.locale.provider.CalendarDataUtility; 39 // import sun.util.locale.provider.LocaleProviderAdapter; 40 // import sun.util.locale.provider.LocaleResources; 41 42 /** 43 * A standard set of fields. 44 * !(p) 45 * This set of fields provide field-based access to manipulate a date, time or date-time. 46 * The standard set of fields can be extended by implementing {@link TemporalField}. 47 * !(p) 48 * These fields are intended to be applicable _in multiple calendar systems. 49 * For example, most non-ISO calendar systems define dates as a year, month and day, 50 * just with slightly different rules. 51 * The documentation of each field explains how it operates. 52 * 53 * @implSpec 54 * This is a final, immutable and thread-safe enum. 55 * 56 * @since 1.8 57 */ 58 public class ChronoField : TemporalField 59 { 60 61 /** 62 * The nano-of-second. 63 * !(p) 64 * This counts the nanosecond within the second, from 0 to 999,999,999. 65 * This field has the same meaning for all calendar systems. 66 * !(p) 67 * This field is used to represent the nano-of-second handling any fraction of the second. 68 * Implementations of {@code TemporalAccessor} should provide a value for this field if 69 * they can return a value for {@link #SECOND_OF_MINUTE}, {@link #SECOND_OF_DAY} or 70 * {@link #INSTANT_SECONDS} filling unknown precision with zero. 71 * !(p) 72 * When this field is used for setting a value, it should set as much precision as the 73 * object stores, using integer division to remove excess precision. 74 * For example, if the {@code TemporalAccessor} stores time to millisecond precision, 75 * then the nano-of-second must be divided by 1,000,000 before replacing the milli-of-second. 76 * !(p) 77 * When parsing this field it behaves equivalent to the following: 78 * The value is validated _in strict and smart mode but not _in lenient mode. 79 * The field is resolved _in combination with {@code MILLI_OF_SECOND} and {@code MICRO_OF_SECOND}. 80 */ 81 //__gshared ChronoField NANO_OF_SECOND; 82 /** 83 * The nano-of-day. 84 * !(p) 85 * This counts the nanosecond within the day, from 0 to (24 * 60 * 60 * 1,000,000,000) - 1. 86 * This field has the same meaning for all calendar systems. 87 * !(p) 88 * This field is used to represent the nano-of-day handling any fraction of the second. 89 * Implementations of {@code TemporalAccessor} should provide a value for this field if 90 * they can return a value for {@link #SECOND_OF_DAY} filling unknown precision with zero. 91 * !(p) 92 * When parsing this field it behaves equivalent to the following: 93 * The value is validated _in strict and smart mode but not _in lenient mode. 94 * The value is split to form {@code NANO_OF_SECOND}, {@code SECOND_OF_MINUTE}, 95 * {@code MINUTE_OF_HOUR} and {@code HOUR_OF_DAY} fields. 96 */ 97 //__gshared ChronoField NANO_OF_DAY; 98 /** 99 * The micro-of-second. 100 * !(p) 101 * This counts the microsecond within the second, from 0 to 999,999. 102 * This field has the same meaning for all calendar systems. 103 * !(p) 104 * This field is used to represent the micro-of-second handling any fraction of the second. 105 * Implementations of {@code TemporalAccessor} should provide a value for this field if 106 * they can return a value for {@link #SECOND_OF_MINUTE}, {@link #SECOND_OF_DAY} or 107 * {@link #INSTANT_SECONDS} filling unknown precision with zero. 108 * !(p) 109 * When this field is used for setting a value, it should behave _in the same way as 110 * setting {@link #NANO_OF_SECOND} with the value multiplied by 1,000. 111 * !(p) 112 * When parsing this field it behaves equivalent to the following: 113 * The value is validated _in strict and smart mode but not _in lenient mode. 114 * The field is resolved _in combination with {@code MILLI_OF_SECOND} to produce 115 * {@code NANO_OF_SECOND}. 116 */ 117 //__gshared ChronoField MICRO_OF_SECOND; 118 /** 119 * The micro-of-day. 120 * !(p) 121 * This counts the microsecond within the day, from 0 to (24 * 60 * 60 * 1,000,000) - 1. 122 * This field has the same meaning for all calendar systems. 123 * !(p) 124 * This field is used to represent the micro-of-day handling any fraction of the second. 125 * Implementations of {@code TemporalAccessor} should provide a value for this field if 126 * they can return a value for {@link #SECOND_OF_DAY} filling unknown precision with zero. 127 * !(p) 128 * When this field is used for setting a value, it should behave _in the same way as 129 * setting {@link #NANO_OF_DAY} with the value multiplied by 1,000. 130 * !(p) 131 * When parsing this field it behaves equivalent to the following: 132 * The value is validated _in strict and smart mode but not _in lenient mode. 133 * The value is split to form {@code MICRO_OF_SECOND}, {@code SECOND_OF_MINUTE}, 134 * {@code MINUTE_OF_HOUR} and {@code HOUR_OF_DAY} fields. 135 */ 136 //__gshared ChronoField MICRO_OF_DAY; 137 /** 138 * The milli-of-second. 139 * !(p) 140 * This counts the millisecond within the second, from 0 to 999. 141 * This field has the same meaning for all calendar systems. 142 * !(p) 143 * This field is used to represent the milli-of-second handling any fraction of the second. 144 * Implementations of {@code TemporalAccessor} should provide a value for this field if 145 * they can return a value for {@link #SECOND_OF_MINUTE}, {@link #SECOND_OF_DAY} or 146 * {@link #INSTANT_SECONDS} filling unknown precision with zero. 147 * !(p) 148 * When this field is used for setting a value, it should behave _in the same way as 149 * setting {@link #NANO_OF_SECOND} with the value multiplied by 1,000,000. 150 * !(p) 151 * When parsing this field it behaves equivalent to the following: 152 * The value is validated _in strict and smart mode but not _in lenient mode. 153 * The field is resolved _in combination with {@code MICRO_OF_SECOND} to produce 154 * {@code NANO_OF_SECOND}. 155 */ 156 //__gshared ChronoField MILLI_OF_SECOND; 157 /** 158 * The milli-of-day. 159 * !(p) 160 * This counts the millisecond within the day, from 0 to (24 * 60 * 60 * 1,000) - 1. 161 * This field has the same meaning for all calendar systems. 162 * !(p) 163 * This field is used to represent the milli-of-day handling any fraction of the second. 164 * Implementations of {@code TemporalAccessor} should provide a value for this field if 165 * they can return a value for {@link #SECOND_OF_DAY} filling unknown precision with zero. 166 * !(p) 167 * When this field is used for setting a value, it should behave _in the same way as 168 * setting {@link #NANO_OF_DAY} with the value multiplied by 1,000,000. 169 * !(p) 170 * When parsing this field it behaves equivalent to the following: 171 * The value is validated _in strict and smart mode but not _in lenient mode. 172 * The value is split to form {@code MILLI_OF_SECOND}, {@code SECOND_OF_MINUTE}, 173 * {@code MINUTE_OF_HOUR} and {@code HOUR_OF_DAY} fields. 174 */ 175 //__gshared ChronoField MILLI_OF_DAY; 176 /** 177 * The second-of-minute. 178 * !(p) 179 * This counts the second within the minute, from 0 to 59. 180 * This field has the same meaning for all calendar systems. 181 * !(p) 182 * When parsing this field it behaves equivalent to the following: 183 * The value is validated _in strict and smart mode but not _in lenient mode. 184 */ 185 //__gshared ChronoField SECOND_OF_MINUTE; 186 /** 187 * The second-of-day. 188 * !(p) 189 * This counts the second within the day, from 0 to (24 * 60 * 60) - 1. 190 * This field has the same meaning for all calendar systems. 191 * !(p) 192 * When parsing this field it behaves equivalent to the following: 193 * The value is validated _in strict and smart mode but not _in lenient mode. 194 * The value is split to form {@code SECOND_OF_MINUTE}, {@code MINUTE_OF_HOUR} 195 * and {@code HOUR_OF_DAY} fields. 196 */ 197 //__gshared ChronoField SECOND_OF_DAY; 198 /** 199 * The minute-of-hour. 200 * !(p) 201 * This counts the minute within the hour, from 0 to 59. 202 * This field has the same meaning for all calendar systems. 203 * !(p) 204 * When parsing this field it behaves equivalent to the following: 205 * The value is validated _in strict and smart mode but not _in lenient mode. 206 */ 207 //__gshared ChronoField MINUTE_OF_HOUR; 208 /** 209 * The minute-of-day. 210 * !(p) 211 * This counts the minute within the day, from 0 to (24 * 60) - 1. 212 * This field has the same meaning for all calendar systems. 213 * !(p) 214 * When parsing this field it behaves equivalent to the following: 215 * The value is validated _in strict and smart mode but not _in lenient mode. 216 * The value is split to form {@code MINUTE_OF_HOUR} and {@code HOUR_OF_DAY} fields. 217 */ 218 //__gshared ChronoField MINUTE_OF_DAY; 219 /** 220 * The hour-of-am-pm. 221 * !(p) 222 * This counts the hour within the AM/PM, from 0 to 11. 223 * This is the hour that would be observed on a standard 12-hour digital clock. 224 * This field has the same meaning for all calendar systems. 225 * !(p) 226 * When parsing this field it behaves equivalent to the following: 227 * The value is validated from 0 to 11 _in strict and smart mode. 228 * In lenient mode the value is not validated. It is combined with 229 * {@code AMPM_OF_DAY} to form {@code HOUR_OF_DAY} by multiplying 230 * the {AMPM_OF_DAY} value by 12. 231 * !(p) 232 * See {@link #CLOCK_HOUR_OF_AMPM} for the related field that counts hours from 1 to 12. 233 */ 234 //__gshared ChronoField HOUR_OF_AMPM; 235 /** 236 * The clock-hour-of-am-pm. 237 * !(p) 238 * This counts the hour within the AM/PM, from 1 to 12. 239 * This is the hour that would be observed on a standard 12-hour analog wall clock. 240 * This field has the same meaning for all calendar systems. 241 * !(p) 242 * When parsing this field it behaves equivalent to the following: 243 * The value is validated from 1 to 12 _in strict mode and from 244 * 0 to 12 _in smart mode. In lenient mode the value is not validated. 245 * The field is converted to an {@code HOUR_OF_AMPM} with the same value, 246 * unless the value is 12, _in which case it is converted to 0. 247 * !(p) 248 * See {@link #HOUR_OF_AMPM} for the related field that counts hours from 0 to 11. 249 */ 250 //__gshared ChronoField CLOCK_HOUR_OF_AMPM; 251 /** 252 * The hour-of-day. 253 * !(p) 254 * This counts the hour within the day, from 0 to 23. 255 * This is the hour that would be observed on a standard 24-hour digital clock. 256 * This field has the same meaning for all calendar systems. 257 * !(p) 258 * When parsing this field it behaves equivalent to the following: 259 * The value is validated _in strict and smart mode but not _in lenient mode. 260 * The field is combined with {@code MINUTE_OF_HOUR}, {@code SECOND_OF_MINUTE} and 261 * {@code NANO_OF_SECOND} to produce a {@code LocalTime}. 262 * In lenient mode, any excess days are added to the parsed date, or 263 * made available via {@link hunt.time.format.DateTimeFormatter#parsedExcessDays()}. 264 * !(p) 265 * See {@link #CLOCK_HOUR_OF_DAY} for the related field that counts hours from 1 to 24. 266 */ 267 //__gshared ChronoField HOUR_OF_DAY; 268 /** 269 * The clock-hour-of-day. 270 * !(p) 271 * This counts the hour within the day, from 1 to 24. 272 * This is the hour that would be observed on a 24-hour analog wall clock. 273 * This field has the same meaning for all calendar systems. 274 * !(p) 275 * When parsing this field it behaves equivalent to the following: 276 * The value is validated from 1 to 24 _in strict mode and from 277 * 0 to 24 _in smart mode. In lenient mode the value is not validated. 278 * The field is converted to an {@code HOUR_OF_DAY} with the same value, 279 * unless the value is 24, _in which case it is converted to 0. 280 * !(p) 281 * See {@link #HOUR_OF_DAY} for the related field that counts hours from 0 to 23. 282 */ 283 //__gshared ChronoField CLOCK_HOUR_OF_DAY; 284 /** 285 * The am-pm-of-day. 286 * !(p) 287 * This counts the AM/PM within the day, from 0 (AM) to 1 (PM). 288 * This field has the same meaning for all calendar systems. 289 * !(p) 290 * When parsing this field it behaves equivalent to the following: 291 * The value is validated from 0 to 1 _in strict and smart mode. 292 * In lenient mode the value is not validated. It is combined with 293 * {@code HOUR_OF_AMPM} to form {@code HOUR_OF_DAY} by multiplying 294 * the {AMPM_OF_DAY} value by 12. 295 */ 296 //__gshared ChronoField AMPM_OF_DAY; 297 /** 298 * The day-of-week, such as Tuesday. 299 * !(p) 300 * This represents the standard concept of the day of the week. 301 * In the default ISO calendar system, this has values from Monday (1) to Sunday (7). 302 * The {@link DayOfWeek} class can be used to interpret the result. 303 * !(p) 304 * Most non-ISO calendar systems also define a seven day week that aligns with ISO. 305 * Those calendar systems must also use the same numbering system, from Monday (1) to 306 * Sunday (7), which allows {@code DayOfWeek} to be used. 307 * !(p) 308 * Calendar systems that do not have a standard seven day week should implement this field 309 * if they have a similar concept of named or numbered days within a period similar 310 * to a week. It is recommended that the numbering starts from 1. 311 */ 312 //__gshared ChronoField DAY_OF_WEEK; 313 /** 314 * The aligned day-of-week within a month. 315 * !(p) 316 * This represents concept of the count of days within the period of a week 317 * where the weeks are aligned to the start of the month. 318 * This field is typically used with {@link #ALIGNED_WEEK_OF_MONTH}. 319 * !(p) 320 * For example, _in a calendar systems with a seven day week, the first aligned-week-of-month 321 * starts on day-of-month 1, the second aligned-week starts on day-of-month 8, and so on. 322 * Within each of these aligned-weeks, the days are numbered from 1 to 7 and returned 323 * as the value of this field. 324 * As such, day-of-month 1 to 7 will have aligned-day-of-week values from 1 to 7. 325 * And day-of-month 8 to 14 will repeat this with aligned-day-of-week values from 1 to 7. 326 * !(p) 327 * Calendar systems that do not have a seven day week should typically implement this 328 * field _in the same way, but using the alternate week length. 329 */ 330 //__gshared ChronoField ALIGNED_DAY_OF_WEEK_IN_MONTH; 331 /** 332 * The aligned day-of-week within a year. 333 * !(p) 334 * This represents concept of the count of days within the period of a week 335 * where the weeks are aligned to the start of the year. 336 * This field is typically used with {@link #ALIGNED_WEEK_OF_YEAR}. 337 * !(p) 338 * For example, _in a calendar systems with a seven day week, the first aligned-week-of-year 339 * starts on day-of-year 1, the second aligned-week starts on day-of-year 8, and so on. 340 * Within each of these aligned-weeks, the days are numbered from 1 to 7 and returned 341 * as the value of this field. 342 * As such, day-of-year 1 to 7 will have aligned-day-of-week values from 1 to 7. 343 * And day-of-year 8 to 14 will repeat this with aligned-day-of-week values from 1 to 7. 344 * !(p) 345 * Calendar systems that do not have a seven day week should typically implement this 346 * field _in the same way, but using the alternate week length. 347 */ 348 //__gshared ChronoField ALIGNED_DAY_OF_WEEK_IN_YEAR; 349 /** 350 * The day-of-month. 351 * !(p) 352 * This represents the concept of the day within the month. 353 * In the default ISO calendar system, this has values from 1 to 31 _in most months. 354 * April, June, September, November have days from 1 to 30, while February has days 355 * from 1 to 28, or 29 _in a leap year. 356 * !(p) 357 * Non-ISO calendar systems should implement this field using the most recognized 358 * day-of-month values for users of the calendar system. 359 * Normally, this is a count of days from 1 to the length of the month. 360 */ 361 //__gshared ChronoField DAY_OF_MONTH; 362 /** 363 * The day-of-year. 364 * !(p) 365 * This represents the concept of the day within the year. 366 * In the default ISO calendar system, this has values from 1 to 365 _in standard 367 * years and 1 to 366 _in leap years. 368 * !(p) 369 * Non-ISO calendar systems should implement this field using the most recognized 370 * day-of-year values for users of the calendar system. 371 * Normally, this is a count of days from 1 to the length of the year. 372 * !(p) 373 * Note that a non-ISO calendar system may have year numbering system that changes 374 * at a different point to the natural reset _in the month numbering. An example 375 * of this is the Japanese calendar system where a change of era, which resets 376 * the year number to 1, can happen on any date. The era and year reset also cause 377 * the day-of-year to be reset to 1, but not the month-of-year or day-of-month. 378 */ 379 //__gshared ChronoField DAY_OF_YEAR; 380 /** 381 * The epoch-day, based on the Java epoch of 1970-01-01 (ISO). 382 * !(p) 383 * This field is the sequential count of days where 1970-01-01 (ISO) is zero. 384 * Note that this uses the !(i)local</i> time-line, ignoring offset and time-zone. 385 * !(p) 386 * This field is strictly defined to have the same meaning _in all calendar systems. 387 * This is necessary to ensure interoperation between calendars. 388 * !(p) 389 * Range of EpochDay is between (LocalDate.MIN.toEpochDay(), LocalDate.MAX.toEpochDay()) 390 * both inclusive. 391 */ 392 //__gshared ChronoField EPOCH_DAY; 393 /** 394 * The aligned week within a month. 395 * !(p) 396 * This represents concept of the count of weeks within the period of a month 397 * where the weeks are aligned to the start of the month. 398 * This field is typically used with {@link #ALIGNED_DAY_OF_WEEK_IN_MONTH}. 399 * !(p) 400 * For example, _in a calendar systems with a seven day week, the first aligned-week-of-month 401 * starts on day-of-month 1, the second aligned-week starts on day-of-month 8, and so on. 402 * Thus, day-of-month values 1 to 7 are _in aligned-week 1, while day-of-month values 403 * 8 to 14 are _in aligned-week 2, and so on. 404 * !(p) 405 * Calendar systems that do not have a seven day week should typically implement this 406 * field _in the same way, but using the alternate week length. 407 */ 408 //__gshared ChronoField ALIGNED_WEEK_OF_MONTH; 409 /** 410 * The aligned week within a year. 411 * !(p) 412 * This represents concept of the count of weeks within the period of a year 413 * where the weeks are aligned to the start of the year. 414 * This field is typically used with {@link #ALIGNED_DAY_OF_WEEK_IN_YEAR}. 415 * !(p) 416 * For example, _in a calendar systems with a seven day week, the first aligned-week-of-year 417 * starts on day-of-year 1, the second aligned-week starts on day-of-year 8, and so on. 418 * Thus, day-of-year values 1 to 7 are _in aligned-week 1, while day-of-year values 419 * 8 to 14 are _in aligned-week 2, and so on. 420 * !(p) 421 * Calendar systems that do not have a seven day week should typically implement this 422 * field _in the same way, but using the alternate week length. 423 */ 424 //__gshared ChronoField ALIGNED_WEEK_OF_YEAR; 425 /** 426 * The month-of-year, such as March. 427 * !(p) 428 * This represents the concept of the month within the year. 429 * In the default ISO calendar system, this has values from January (1) to December (12). 430 * !(p) 431 * Non-ISO calendar systems should implement this field using the most recognized 432 * month-of-year values for users of the calendar system. 433 * Normally, this is a count of months starting from 1. 434 */ 435 //__gshared ChronoField MONTH_OF_YEAR; 436 /** 437 * The proleptic-month based, counting months sequentially from year 0. 438 * !(p) 439 * This field is the sequential count of months where the first month 440 * _in proleptic-year zero has the value zero. 441 * Later months have increasingly larger values. 442 * Earlier months have increasingly small values. 443 * There are no gaps or breaks _in the sequence of months. 444 * Note that this uses the !(i)local</i> time-line, ignoring offset and time-zone. 445 * !(p) 446 * In the default ISO calendar system, June 2012 would have the value 447 * {@code (2012 * 12 + 6 - 1)}. This field is primarily for internal use. 448 * !(p) 449 * Non-ISO calendar systems must implement this field as per the definition above. 450 * It is just a simple zero-based count of elapsed months from the start of proleptic-year 0. 451 * All calendar systems with a full proleptic-year definition will have a year zero. 452 * If the calendar system has a minimum year that excludes year zero, then one must 453 * be extrapolated _in order for this method to be defined. 454 */ 455 //__gshared ChronoField PROLEPTIC_MONTH; 456 /** 457 * The year within the era. 458 * !(p) 459 * This represents the concept of the year within the era. 460 * This field is typically used with {@link #ERA}. 461 * !(p) 462 * The standard mental model for a date is based on three concepts - year, month and day. 463 * These map onto the {@code YEAR}, {@code MONTH_OF_YEAR} and {@code DAY_OF_MONTH} fields. 464 * Note that there is no reference to eras. 465 * The full model for a date requires four concepts - era, year, month and day. These map onto 466 * the {@code ERA}, {@code YEAR_OF_ERA}, {@code MONTH_OF_YEAR} and {@code DAY_OF_MONTH} fields. 467 * Whether this field or {@code YEAR} is used depends on which mental model is being used. 468 * See {@link ChronoLocalDate} for more discussion on this topic. 469 * !(p) 470 * In the default ISO calendar system, there are two eras defined, 'BCE' and 'CE'. 471 * The era 'CE' is the one currently _in use and year-of-era runs from 1 to the maximum value. 472 * The era 'BCE' is the previous era, and the year-of-era runs backwards. 473 * !(p) 474 * For example, subtracting a year each time yield the following:!(br) 475 * - year-proleptic 2 = 'CE' year-of-era 2!(br) 476 * - year-proleptic 1 = 'CE' year-of-era 1!(br) 477 * - year-proleptic 0 = 'BCE' year-of-era 1!(br) 478 * - year-proleptic -1 = 'BCE' year-of-era 2!(br) 479 * !(p) 480 * Note that the ISO-8601 standard does not actually define eras. 481 * Note also that the ISO eras do not align with the well-known AD/BC eras due to the 482 * change between the Julian and Gregorian calendar systems. 483 * !(p) 484 * Non-ISO calendar systems should implement this field using the most recognized 485 * year-of-era value for users of the calendar system. 486 * Since most calendar systems have only two eras, the year-of-era numbering approach 487 * will typically be the same as that used by the ISO calendar system. 488 * The year-of-era value should typically always be positive, however this is not required. 489 */ 490 //__gshared ChronoField YEAR_OF_ERA; 491 /** 492 * The proleptic year, such as 2012. 493 * !(p) 494 * This represents the concept of the year, counting sequentially and using negative numbers. 495 * The proleptic year is not interpreted _in terms of the era. 496 * See {@link #YEAR_OF_ERA} for an example showing the mapping from proleptic year to year-of-era. 497 * !(p) 498 * The standard mental model for a date is based on three concepts - year, month and day. 499 * These map onto the {@code YEAR}, {@code MONTH_OF_YEAR} and {@code DAY_OF_MONTH} fields. 500 * Note that there is no reference to eras. 501 * The full model for a date requires four concepts - era, year, month and day. These map onto 502 * the {@code ERA}, {@code YEAR_OF_ERA}, {@code MONTH_OF_YEAR} and {@code DAY_OF_MONTH} fields. 503 * Whether this field or {@code YEAR_OF_ERA} is used depends on which mental model is being used. 504 * See {@link ChronoLocalDate} for more discussion on this topic. 505 * !(p) 506 * Non-ISO calendar systems should implement this field as follows. 507 * If the calendar system has only two eras, before and after a fixed date, then the 508 * proleptic-year value must be the same as the year-of-era value for the later era, 509 * and increasingly negative for the earlier era. 510 * If the calendar system has more than two eras, then the proleptic-year value may be 511 * defined with any appropriate value, although defining it to be the same as ISO may be 512 * the best option. 513 */ 514 //__gshared ChronoField YEAR; 515 /** 516 * The era. 517 * !(p) 518 * This represents the concept of the era, which is the largest division of the time-line. 519 * This field is typically used with {@link #YEAR_OF_ERA}. 520 * !(p) 521 * In the default ISO calendar system, there are two eras defined, 'BCE' and 'CE'. 522 * The era 'CE' is the one currently _in use and year-of-era runs from 1 to the maximum value. 523 * The era 'BCE' is the previous era, and the year-of-era runs backwards. 524 * See {@link #YEAR_OF_ERA} for a full example. 525 * !(p) 526 * Non-ISO calendar systems should implement this field to define eras. 527 * The value of the era that was active on 1970-01-01 (ISO) must be assigned the value 1. 528 * Earlier eras must have sequentially smaller values. 529 * Later eras must have sequentially larger values, 530 */ 531 //__gshared ChronoField ERA; 532 /** 533 * The instant epoch-seconds. 534 * !(p) 535 * This represents the concept of the sequential count of seconds where 536 * 1970-01-01T00:00Z (ISO) is zero. 537 * This field may be used with {@link #NANO_OF_SECOND} to represent the fraction of the second. 538 * !(p) 539 * An {@link Instant} represents an instantaneous point on the time-line. 540 * On their own, an instant has insufficient information to allow a local date-time to be obtained. 541 * Only when paired with an offset or time-zone can the local date or time be calculated. 542 * !(p) 543 * This field is strictly defined to have the same meaning _in all calendar systems. 544 * This is necessary to ensure interoperation between calendars. 545 */ 546 //__gshared ChronoField INSTANT_SECONDS; 547 /** 548 * The offset from UTC/Greenwich. 549 * !(p) 550 * This represents the concept of the offset _in seconds of local time from UTC/Greenwich. 551 * !(p) 552 * A {@link ZoneOffset} represents the period of time that local time differs from UTC/Greenwich. 553 * This is usually a fixed number of hours and minutes. 554 * It is equivalent to the {@link ZoneOffset#getTotalSeconds() total amount} of the offset _in seconds. 555 * For example, during the winter Paris has an offset of {@code +01:00}, which is 3600 seconds. 556 * !(p) 557 * This field is strictly defined to have the same meaning _in all calendar systems. 558 * This is necessary to ensure interoperation between calendars. 559 */ 560 //__gshared ChronoField OFFSET_SECONDS; 561 562 // shared static this() 563 // { 564 // // import hunt.logging; 565 // /* version(HUNT_DEBUG) */ logDebug("ChronoField shared static this begin"); 566 // ChronoField.NANO_OF_SECOND = new ChronoField(0, "NanoOfSecond", 567 // ChronoUnit.NANOS, ChronoUnit.SECONDS, ValueRange.of(0, 999_999_999)); 568 mixin(MakeGlobalVar!ChronoField("NANO_OF_SECOND",`new ChronoField(0, "NanoOfSecond", 569 ChronoUnit.NANOS, ChronoUnit.SECONDS, ValueRange.of(0, 999_999_999))`)); 570 571 // ChronoField.NANO_OF_DAY = new ChronoField(1, "NanoOfDay", ChronoUnit.NANOS, 572 // ChronoUnit.DAYS, ValueRange.of(0, 86400L * 1000_000_000L - 1)); 573 mixin(MakeGlobalVar!ChronoField("NANO_OF_DAY",`new ChronoField(1, "NanoOfDay", ChronoUnit.NANOS, 574 ChronoUnit.DAYS, ValueRange.of(0, 86400L * 1000_000_000L - 1))`)); 575 576 // ChronoField.MICRO_OF_SECOND = new ChronoField(2, "MicroOfSecond", 577 // ChronoUnit.MICROS, ChronoUnit.SECONDS, ValueRange.of(0, 999_999)); 578 mixin(MakeGlobalVar!ChronoField("MICRO_OF_SECOND",`new ChronoField(2, "MicroOfSecond", 579 ChronoUnit.MICROS, ChronoUnit.SECONDS, ValueRange.of(0, 999_999))`)); 580 581 // ChronoField.MICRO_OF_DAY = new ChronoField(3, "MicroOfDay", ChronoUnit.MICROS, 582 // ChronoUnit.DAYS, ValueRange.of(0, 86400L * 1000_000L - 1)); 583 mixin(MakeGlobalVar!ChronoField("MICRO_OF_DAY",`new ChronoField(3, "MicroOfDay", ChronoUnit.MICROS, 584 ChronoUnit.DAYS, ValueRange.of(0, 86400L * 1000_000L - 1))`)); 585 586 // ChronoField.MILLI_OF_SECOND = new ChronoField(4, "MilliOfSecond", 587 // ChronoUnit.MILLIS, ChronoUnit.SECONDS, ValueRange.of(0, 999)); 588 mixin(MakeGlobalVar!ChronoField("MILLI_OF_SECOND",`new ChronoField(4, "MilliOfSecond", 589 ChronoUnit.MILLIS, ChronoUnit.SECONDS, ValueRange.of(0, 999))`)); 590 591 // ChronoField.MILLI_OF_DAY = new ChronoField(5, "MilliOfDay", 592 // ChronoUnit.MILLIS, ChronoUnit.DAYS, ValueRange.of(0, 86400L * 1000L - 1)); 593 mixin(MakeGlobalVar!ChronoField("MILLI_OF_DAY",`new ChronoField(5, "MilliOfDay", 594 ChronoUnit.MILLIS, ChronoUnit.DAYS, ValueRange.of(0, 86400L * 1000L - 1))`)); 595 596 597 // ChronoField.SECOND_OF_MINUTE = new ChronoField(6, "SecondOfMinute", 598 // ChronoUnit.SECONDS, ChronoUnit.MINUTES, ValueRange.of(0, 59), "second"); 599 mixin(MakeGlobalVar!ChronoField("SECOND_OF_MINUTE",`new ChronoField(6, "SecondOfMinute", 600 ChronoUnit.SECONDS, ChronoUnit.MINUTES, ValueRange.of(0, 59), "second")`)); 601 602 // ChronoField.SECOND_OF_DAY = new ChronoField(7, "SecondOfDay", 603 // ChronoUnit.SECONDS, ChronoUnit.DAYS, ValueRange.of(0, 86400L - 1)); 604 mixin(MakeGlobalVar!ChronoField("SECOND_OF_DAY",`new ChronoField(7, "SecondOfDay", 605 ChronoUnit.SECONDS, ChronoUnit.DAYS, ValueRange.of(0, 86400L - 1))`)); 606 607 // ChronoField.MINUTE_OF_HOUR = new ChronoField(8, "MinuteOfHour", 608 // ChronoUnit.MINUTES, ChronoUnit.HOURS, ValueRange.of(0, 59), "minute"); 609 mixin(MakeGlobalVar!ChronoField("MINUTE_OF_HOUR",`new ChronoField(8, "MinuteOfHour", 610 ChronoUnit.MINUTES, ChronoUnit.HOURS, ValueRange.of(0, 59), "minute")`)); 611 612 // ChronoField.MINUTE_OF_DAY = new ChronoField(9, "MinuteOfDay", 613 // ChronoUnit.MINUTES, ChronoUnit.DAYS, ValueRange.of(0, (24 * 60) - 1)); 614 mixin(MakeGlobalVar!ChronoField("MINUTE_OF_DAY",`new ChronoField(9, "MinuteOfDay", 615 ChronoUnit.MINUTES, ChronoUnit.DAYS, ValueRange.of(0, (24 * 60) - 1))`)); 616 617 // ChronoField.HOUR_OF_AMPM = new ChronoField(10, "HourOfAmPm", 618 // ChronoUnit.HOURS, ChronoUnit.HALF_DAYS, ValueRange.of(0, 11)); 619 mixin(MakeGlobalVar!ChronoField("HOUR_OF_AMPM",`new ChronoField(10, "HourOfAmPm", 620 ChronoUnit.HOURS, ChronoUnit.HALF_DAYS, ValueRange.of(0, 11))`)); 621 622 // ChronoField.CLOCK_HOUR_OF_AMPM = new ChronoField(11, "ClockHourOfAmPm", 623 // ChronoUnit.HOURS, ChronoUnit.HALF_DAYS, ValueRange.of(1, 12)); 624 mixin(MakeGlobalVar!ChronoField("CLOCK_HOUR_OF_AMPM",`new ChronoField(11, "ClockHourOfAmPm", 625 ChronoUnit.HOURS, ChronoUnit.HALF_DAYS, ValueRange.of(1, 12))`)); 626 627 // ChronoField.HOUR_OF_DAY = new ChronoField(12, "HourOfDay", 628 // ChronoUnit.HOURS, ChronoUnit.DAYS, ValueRange.of(0, 23), "hour"); 629 mixin(MakeGlobalVar!ChronoField("HOUR_OF_DAY",`new ChronoField(12, "HourOfDay", 630 ChronoUnit.HOURS, ChronoUnit.DAYS, ValueRange.of(0, 23), "hour")`)); 631 632 // ChronoField.CLOCK_HOUR_OF_DAY = new ChronoField(13, "ClockHourOfDay", 633 // ChronoUnit.HOURS, ChronoUnit.DAYS, ValueRange.of(1, 24)); 634 mixin(MakeGlobalVar!ChronoField("CLOCK_HOUR_OF_DAY",`new ChronoField(13, "ClockHourOfDay", 635 ChronoUnit.HOURS, ChronoUnit.DAYS, ValueRange.of(1, 24))`)); 636 637 // ChronoField.AMPM_OF_DAY = new ChronoField(14, "AmPmOfDay", 638 // ChronoUnit.HALF_DAYS, ChronoUnit.DAYS, ValueRange.of(0, 1), "dayperiod"); 639 mixin(MakeGlobalVar!ChronoField("AMPM_OF_DAY",`new ChronoField(14, "AmPmOfDay", 640 ChronoUnit.HALF_DAYS, ChronoUnit.DAYS, ValueRange.of(0, 1), "dayperiod")`)); 641 642 // ChronoField.DAY_OF_WEEK = new ChronoField(15, "DayOfWeek", 643 // ChronoUnit.DAYS, ChronoUnit.WEEKS, ValueRange.of(1, 7), "weekday"); 644 mixin(MakeGlobalVar!ChronoField("DAY_OF_WEEK",`new ChronoField(15, "DayOfWeek", 645 ChronoUnit.DAYS, ChronoUnit.WEEKS, ValueRange.of(1, 7), "weekday")`)); 646 647 // ChronoField.ALIGNED_DAY_OF_WEEK_IN_MONTH = new ChronoField(16, 648 // "AlignedDayOfWeekInMonth", ChronoUnit.DAYS, ChronoUnit.WEEKS, ValueRange.of(1, 7)); 649 mixin(MakeGlobalVar!ChronoField("ALIGNED_DAY_OF_WEEK_IN_MONTH",`new ChronoField(16, 650 "AlignedDayOfWeekInMonth", ChronoUnit.DAYS, ChronoUnit.WEEKS, ValueRange.of(1, 7))`)); 651 652 // ChronoField.ALIGNED_DAY_OF_WEEK_IN_YEAR = new ChronoField(17, 653 // "AlignedDayOfWeekInYear", ChronoUnit.DAYS, ChronoUnit.WEEKS, ValueRange.of(1, 7)); 654 mixin(MakeGlobalVar!ChronoField("ALIGNED_DAY_OF_WEEK_IN_YEAR",`new ChronoField(17, 655 "AlignedDayOfWeekInYear", ChronoUnit.DAYS, ChronoUnit.WEEKS, ValueRange.of(1, 7))`)); 656 657 // ChronoField.DAY_OF_MONTH = new ChronoField(18, "DayOfMonth", 658 // ChronoUnit.DAYS, ChronoUnit.MONTHS, ValueRange.of(1, 28, 31), "day"); 659 mixin(MakeGlobalVar!ChronoField("DAY_OF_MONTH",`new ChronoField(18, "DayOfMonth", 660 ChronoUnit.DAYS, ChronoUnit.MONTHS, ValueRange.of(1, 28, 31), "day")`)); 661 662 // ChronoField.DAY_OF_YEAR = new ChronoField(19, "DayOfYear", 663 // ChronoUnit.DAYS, ChronoUnit.YEARS, ValueRange.of(1, 365, 366)); 664 mixin(MakeGlobalVar!ChronoField("DAY_OF_YEAR",`new ChronoField(19, "DayOfYear", 665 ChronoUnit.DAYS, ChronoUnit.YEARS, ValueRange.of(1, 365, 366))`)); 666 667 // ChronoField.EPOCH_DAY = new ChronoField(20, "EpochDay", ChronoUnit.DAYS, 668 // ChronoUnit.FOREVER, ValueRange.of(-365243219162L, 365241780471L)); 669 mixin(MakeGlobalVar!ChronoField("EPOCH_DAY",`new ChronoField(20, "EpochDay", ChronoUnit.DAYS, 670 ChronoUnit.FOREVER, ValueRange.of(-365243219162L, 365241780471L))`)); 671 672 // ChronoField.ALIGNED_WEEK_OF_MONTH = new ChronoField(21, "AlignedWeekOfMonth", 673 // ChronoUnit.WEEKS, ChronoUnit.MONTHS, ValueRange.of(1, 4, 5)); 674 mixin(MakeGlobalVar!ChronoField("ALIGNED_WEEK_OF_MONTH",`new ChronoField(21, "AlignedWeekOfMonth", 675 ChronoUnit.WEEKS, ChronoUnit.MONTHS, ValueRange.of(1, 4, 5))`)); 676 677 // ChronoField.ALIGNED_WEEK_OF_YEAR = new ChronoField(22, "AlignedWeekOfYear", 678 // ChronoUnit.WEEKS, ChronoUnit.YEARS, ValueRange.of(1, 53)); 679 mixin(MakeGlobalVar!ChronoField("ALIGNED_WEEK_OF_YEAR",`new ChronoField(22, "AlignedWeekOfYear", 680 ChronoUnit.WEEKS, ChronoUnit.YEARS, ValueRange.of(1, 53))`)); 681 682 // ChronoField.MONTH_OF_YEAR = new ChronoField(23, "MonthOfYear", 683 // ChronoUnit.MONTHS, ChronoUnit.YEARS, ValueRange.of(1, 12), "month"); 684 mixin(MakeGlobalVar!ChronoField("MONTH_OF_YEAR",`new ChronoField(23, "MonthOfYear", 685 ChronoUnit.MONTHS, ChronoUnit.YEARS, ValueRange.of(1, 12), "month")`)); 686 687 // ChronoField.PROLEPTIC_MONTH = new ChronoField(24, "ProlepticMonth", ChronoUnit.MONTHS, 688 // ChronoUnit.FOREVER, ValueRange.of(Year.MIN_VALUE * 12L, Year.MAX_VALUE * 12L + 11)); 689 mixin(MakeGlobalVar!ChronoField("PROLEPTIC_MONTH",`new ChronoField(24, "ProlepticMonth", ChronoUnit.MONTHS, 690 ChronoUnit.FOREVER, ValueRange.of(Year.MIN_VALUE * 12L, Year.MAX_VALUE * 12L + 11))`)); 691 692 // ChronoField.YEAR_OF_ERA = new ChronoField(25, "YearOfEra", ChronoUnit.YEARS, 693 // ChronoUnit.FOREVER, ValueRange.of(1, Year.MAX_VALUE, Year.MAX_VALUE + 1)); 694 mixin(MakeGlobalVar!ChronoField("YEAR_OF_ERA",`new ChronoField(25, "YearOfEra", ChronoUnit.YEARS, 695 ChronoUnit.FOREVER, ValueRange.of(1, Year.MAX_VALUE, Year.MAX_VALUE + 1))`)); 696 697 // ChronoField.YEAR = new ChronoField(26, "Year", ChronoUnit.YEARS, 698 // ChronoUnit.FOREVER, ValueRange.of(Year.MIN_VALUE, Year.MAX_VALUE), "year"); 699 mixin(MakeGlobalVar!ChronoField("YEAR",`new ChronoField(26, "Year", ChronoUnit.YEARS, 700 ChronoUnit.FOREVER, ValueRange.of(Year.MIN_VALUE, Year.MAX_VALUE), "year")`)); 701 702 // ChronoField.ERA = new ChronoField(27, "Era", ChronoUnit.ERAS, 703 // ChronoUnit.FOREVER, ValueRange.of(0, 1), "era"); 704 mixin(MakeGlobalVar!ChronoField("ERA",`new ChronoField(27, "Era", ChronoUnit.ERAS, 705 ChronoUnit.FOREVER, ValueRange.of(0, 1), "era")`)); 706 707 // ChronoField.INSTANT_SECONDS = new ChronoField(28, "InstantSeconds", ChronoUnit.SECONDS, 708 // ChronoUnit.FOREVER, ValueRange.of(Long.MIN_VALUE, Long.MAX_VALUE)); 709 mixin(MakeGlobalVar!ChronoField("INSTANT_SECONDS",`new ChronoField(28, "InstantSeconds", ChronoUnit.SECONDS, 710 ChronoUnit.FOREVER, ValueRange.of(Long.MIN_VALUE, Long.MAX_VALUE))`)); 711 712 // ChronoField.OFFSET_SECONDS = new ChronoField(29, "OffsetSeconds", 713 // ChronoUnit.SECONDS, ChronoUnit.FOREVER, ValueRange.of(-18 * 3600, 18 * 3600)); 714 mixin(MakeGlobalVar!ChronoField("OFFSET_SECONDS",`new ChronoField(29, "OffsetSeconds", 715 ChronoUnit.SECONDS, ChronoUnit.FOREVER, ValueRange.of(-18 * 3600, 18 * 3600))`)); 716 717 718 // import hunt.logging; 719 // /* version(HUNT_DEBUG) */ logDebug("ChronoField shared static this begin"); 720 // } 721 722 723 private string name; 724 private TemporalUnit baseUnit; 725 private TemporalUnit rangeUnit; 726 private ValueRange _range; 727 private string displayNameKey; 728 729 static ChronoField[] _values; 730 private int _ordinal; 731 public int ordinal() 732 { 733 return _ordinal; 734 } 735 736 static ChronoField[] values() 737 { 738 if(_values.length == 0) 739 { 740 ChronoField._values ~= ChronoField.NANO_OF_SECOND; 741 ChronoField._values ~= ChronoField.NANO_OF_DAY; 742 ChronoField._values ~= ChronoField.MICRO_OF_SECOND; 743 ChronoField._values ~= ChronoField.MICRO_OF_DAY; 744 ChronoField._values ~= ChronoField.MILLI_OF_SECOND; 745 ChronoField._values ~= ChronoField.MILLI_OF_DAY; 746 ChronoField._values ~= ChronoField.SECOND_OF_MINUTE; 747 ChronoField._values ~= ChronoField.SECOND_OF_DAY; 748 ChronoField._values ~= ChronoField.MINUTE_OF_HOUR; 749 ChronoField._values ~= ChronoField.MINUTE_OF_DAY; 750 ChronoField._values ~= ChronoField.HOUR_OF_AMPM; 751 ChronoField._values ~= ChronoField.CLOCK_HOUR_OF_AMPM; 752 ChronoField._values ~= ChronoField.HOUR_OF_DAY; 753 ChronoField._values ~= ChronoField.CLOCK_HOUR_OF_DAY; 754 ChronoField._values ~= ChronoField.AMPM_OF_DAY; 755 ChronoField._values ~= ChronoField.DAY_OF_WEEK; 756 ChronoField._values ~= ChronoField.ALIGNED_DAY_OF_WEEK_IN_MONTH; 757 ChronoField._values ~= ChronoField.ALIGNED_DAY_OF_WEEK_IN_YEAR; 758 ChronoField._values ~= ChronoField.DAY_OF_MONTH; 759 ChronoField._values ~= ChronoField.DAY_OF_YEAR; 760 ChronoField._values ~= ChronoField.EPOCH_DAY; 761 ChronoField._values ~= ChronoField.ALIGNED_WEEK_OF_MONTH; 762 ChronoField._values ~= ChronoField.ALIGNED_WEEK_OF_YEAR; 763 ChronoField._values ~= ChronoField.MONTH_OF_YEAR; 764 ChronoField._values ~= ChronoField.PROLEPTIC_MONTH; 765 ChronoField._values ~= ChronoField.YEAR_OF_ERA; 766 ChronoField._values ~= ChronoField.YEAR; 767 ChronoField._values ~= ChronoField.ERA; 768 ChronoField._values ~= ChronoField.INSTANT_SECONDS; 769 ChronoField._values ~= ChronoField.OFFSET_SECONDS; 770 } 771 return _values; 772 } 773 774 this(int ordinal, string name, TemporalUnit baseUnit, 775 TemporalUnit rangeUnit, ValueRange range) 776 { 777 this._ordinal = ordinal; 778 this.name = name; 779 this.baseUnit = baseUnit; 780 this.rangeUnit = rangeUnit; 781 this._range = range; 782 this.displayNameKey = null; 783 } 784 785 this(int ordinal, string name, TemporalUnit baseUnit, 786 TemporalUnit rangeUnit, ValueRange range, string displayNameKey) 787 { 788 this._ordinal = ordinal; 789 this.name = name; 790 this.baseUnit = baseUnit; 791 this.rangeUnit = rangeUnit; 792 this._range = range; 793 this.displayNameKey = displayNameKey; 794 } 795 796 override public string getDisplayName(Locale locale) 797 { 798 assert(locale, "locale"); 799 if (displayNameKey is null) 800 { 801 return name; 802 } 803 ///@gxc 804 // LocaleResources lr = LocaleProviderAdapter.getResourceBundleBased() 805 // .getLocaleResources( 806 // CalendarDataUtility 807 // .findRegionOverride(locale)); 808 // ResourceBundle rb = lr.getJavaTimeFormatData(); 809 // string key = "field." ~ displayNameKey; 810 // return rb.containsKey(key) ? rb.getString(key) : name; 811 return null; 812 } 813 814 override public TemporalUnit getBaseUnit() 815 { 816 return baseUnit; 817 } 818 819 override public TemporalUnit getRangeUnit() 820 { 821 return rangeUnit; 822 } 823 824 /** 825 * Gets the range of valid values for the field. 826 * !(p) 827 * All fields can be expressed as a {@code long} integer. 828 * This method returns an object that describes the valid range for that value. 829 * !(p) 830 * This method returns the range of the field _in the ISO-8601 calendar system. 831 * This range may be incorrect for other calendar systems. 832 * Use {@link Chronology#range(ChronoField)} to access the correct range 833 * for a different calendar system. 834 * !(p) 835 * Note that the result only describes the minimum and maximum valid values 836 * and it is important not to read too much into them. For example, there 837 * could be values within the range that are invalid for the field. 838 * 839 * @return the range of valid values for the field, not null 840 */ 841 override public ValueRange range() 842 { 843 return _range; 844 } 845 846 //----------------------------------------------------------------------- 847 /** 848 * Checks if this field represents a component of a date. 849 * !(p) 850 * Fields from day-of-week to era are date-based. 851 * 852 * @return true if it is a component of a date 853 */ 854 override public bool isDateBased() 855 { 856 return ordinal() >= DAY_OF_WEEK.ordinal() && ordinal() <= ERA.ordinal(); 857 } 858 859 /** 860 * Checks if this field represents a component of a time. 861 * !(p) 862 * Fields from nano-of-second to am-pm-of-day are time-based. 863 * 864 * @return true if it is a component of a time 865 */ 866 override public bool isTimeBased() 867 { 868 return ordinal() < DAY_OF_WEEK.ordinal(); 869 } 870 871 //----------------------------------------------------------------------- 872 /** 873 * Checks that the specified value is valid for this field. 874 * !(p) 875 * This validates that the value is within the outer range of valid values 876 * returned by {@link #range()}. 877 * !(p) 878 * This method checks against the range of the field _in the ISO-8601 calendar system. 879 * This range may be incorrect for other calendar systems. 880 * Use {@link Chronology#range(ChronoField)} to access the correct range 881 * for a different calendar system. 882 * 883 * @param value the value to check 884 * @return the value that was passed _in 885 */ 886 public long checkValidValue(long value) 887 { 888 return range().checkValidValue(value, this); 889 } 890 891 /** 892 * Checks that the specified value is valid and fits _in an {@code int}. 893 * !(p) 894 * This validates that the value is within the outer range of valid values 895 * returned by {@link #range()}. 896 * It also checks that all valid values are within the bounds of an {@code int}. 897 * !(p) 898 * This method checks against the range of the field _in the ISO-8601 calendar system. 899 * This range may be incorrect for other calendar systems. 900 * Use {@link Chronology#range(ChronoField)} to access the correct range 901 * for a different calendar system. 902 * 903 * @param value the value to check 904 * @return the value that was passed _in 905 */ 906 public int checkValidIntValue(long value) 907 { 908 return range().checkValidIntValue(value, this); 909 } 910 911 //----------------------------------------------------------------------- 912 override public bool isSupportedBy(TemporalAccessor temporal) 913 { 914 return temporal.isSupported(this); 915 } 916 917 override public ValueRange rangeRefinedBy(TemporalAccessor temporal) 918 { 919 return temporal.range(this); 920 } 921 922 override public long getFrom(TemporalAccessor temporal) 923 { 924 return temporal.getLong(this); 925 } 926 927 /*@SuppressWarnings("unchecked")*/ 928 override public Temporal adjustInto(Temporal temporal, long newValue) /* if(is(R : Temporal)) */ 929 { 930 return /* cast(Temporal) */ temporal._with(this, newValue); 931 } 932 933 //----------------------------------------------------------------------- 934 override public string toString() 935 { 936 return name; 937 } 938 939 override public bool opEquals(Object obj) 940 { 941 if (this is obj) 942 { 943 return true; 944 } 945 if (cast(ChronoField)(obj) !is null) 946 { 947 ChronoField other = cast(ChronoField) obj; 948 return name == other.name; 949 } 950 return false; 951 } 952 953 override int opCmp(TemporalField obj) 954 { 955 if (cast(ChronoField)(obj) !is null) 956 { 957 ChronoField other = cast(ChronoField) obj; 958 return compare(name, other.name); 959 } 960 return 0; 961 } 962 963 override int opCmp(Object obj) 964 { 965 if (cast(ChronoField)(obj) !is null) 966 { 967 ChronoField other = cast(ChronoField) obj; 968 return compare(name, other.name); 969 } 970 return 0; 971 } 972 973 override TemporalAccessor resolve(Map!(TemporalField, Long) fieldValues, 974 TemporalAccessor partialTemporal, ResolverStyle resolverStyle) 975 { 976 return null; 977 } 978 }