Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

settings.js 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. import LocalZone from "./zones/localZone.js";
  2. import IANAZone from "./zones/IANAZone.js";
  3. import Locale from "./impl/locale.js";
  4. import { normalizeZone } from "./impl/zoneUtil.js";
  5. let now = () => Date.now(),
  6. defaultZone = null, // not setting this directly to LocalZone.instance bc loading order issues
  7. defaultLocale = null,
  8. defaultNumberingSystem = null,
  9. defaultOutputCalendar = null,
  10. throwOnInvalid = false;
  11. /**
  12. * Settings contains static getters and setters that control Luxon's overall behavior. Luxon is a simple library with few options, but the ones it does have live here.
  13. */
  14. export default class Settings {
  15. /**
  16. * Get the callback for returning the current timestamp.
  17. * @type {function}
  18. */
  19. static get now() {
  20. return now;
  21. }
  22. /**
  23. * Set the callback for returning the current timestamp.
  24. * The function should return a number, which will be interpreted as an Epoch millisecond count
  25. * @type {function}
  26. * @example Settings.now = () => Date.now() + 3000 // pretend it is 3 seconds in the future
  27. * @example Settings.now = () => 0 // always pretend it's Jan 1, 1970 at midnight in UTC time
  28. */
  29. static set now(n) {
  30. now = n;
  31. }
  32. /**
  33. * Get the default time zone to create DateTimes in.
  34. * @type {string}
  35. */
  36. static get defaultZoneName() {
  37. return Settings.defaultZone.name;
  38. }
  39. /**
  40. * Set the default time zone to create DateTimes in. Does not affect existing instances.
  41. * @type {string}
  42. */
  43. static set defaultZoneName(z) {
  44. if (!z) {
  45. defaultZone = null;
  46. } else {
  47. defaultZone = normalizeZone(z);
  48. }
  49. }
  50. /**
  51. * Get the default time zone object to create DateTimes in. Does not affect existing instances.
  52. * @type {Zone}
  53. */
  54. static get defaultZone() {
  55. return defaultZone || LocalZone.instance;
  56. }
  57. /**
  58. * Get the default locale to create DateTimes with. Does not affect existing instances.
  59. * @type {string}
  60. */
  61. static get defaultLocale() {
  62. return defaultLocale;
  63. }
  64. /**
  65. * Set the default locale to create DateTimes with. Does not affect existing instances.
  66. * @type {string}
  67. */
  68. static set defaultLocale(locale) {
  69. defaultLocale = locale;
  70. }
  71. /**
  72. * Get the default numbering system to create DateTimes with. Does not affect existing instances.
  73. * @type {string}
  74. */
  75. static get defaultNumberingSystem() {
  76. return defaultNumberingSystem;
  77. }
  78. /**
  79. * Set the default numbering system to create DateTimes with. Does not affect existing instances.
  80. * @type {string}
  81. */
  82. static set defaultNumberingSystem(numberingSystem) {
  83. defaultNumberingSystem = numberingSystem;
  84. }
  85. /**
  86. * Get the default output calendar to create DateTimes with. Does not affect existing instances.
  87. * @type {string}
  88. */
  89. static get defaultOutputCalendar() {
  90. return defaultOutputCalendar;
  91. }
  92. /**
  93. * Set the default output calendar to create DateTimes with. Does not affect existing instances.
  94. * @type {string}
  95. */
  96. static set defaultOutputCalendar(outputCalendar) {
  97. defaultOutputCalendar = outputCalendar;
  98. }
  99. /**
  100. * Get whether Luxon will throw when it encounters invalid DateTimes, Durations, or Intervals
  101. * @type {boolean}
  102. */
  103. static get throwOnInvalid() {
  104. return throwOnInvalid;
  105. }
  106. /**
  107. * Set whether Luxon will throw when it encounters invalid DateTimes, Durations, or Intervals
  108. * @type {boolean}
  109. */
  110. static set throwOnInvalid(t) {
  111. throwOnInvalid = t;
  112. }
  113. /**
  114. * Reset Luxon's global caches. Should only be necessary in testing scenarios.
  115. * @return {void}
  116. */
  117. static resetCaches() {
  118. Locale.resetCache();
  119. IANAZone.resetCache();
  120. }
  121. }