@almighty-shogun/utils 1.10.0 → 1.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/dist/formatDate.d.ts +1 -1
  2. package/dist/formatDate.d.ts.map +1 -1
  3. package/dist/formatDate.js +1 -3
  4. package/dist/formatDateTime.d.ts +1 -1
  5. package/dist/formatDateTime.d.ts.map +1 -1
  6. package/dist/formatDateTime.js +1 -3
  7. package/dist/formatFullDate.d.ts.map +1 -1
  8. package/dist/formatFullDate.js +1 -3
  9. package/dist/formatHour.d.ts +1 -1
  10. package/dist/formatHour.d.ts.map +1 -1
  11. package/dist/formatHour.js +1 -3
  12. package/dist/formatMonth.d.ts +1 -1
  13. package/dist/formatMonth.d.ts.map +1 -1
  14. package/dist/formatMonth.js +1 -3
  15. package/dist/formatTime.d.ts +1 -1
  16. package/dist/formatTime.d.ts.map +1 -1
  17. package/dist/formatTime.js +1 -3
  18. package/dist/formatWeekday.d.ts +1 -1
  19. package/dist/formatWeekday.d.ts.map +1 -1
  20. package/dist/formatWeekday.js +1 -3
  21. package/dist/index.d.ts +0 -2
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +0 -1
  24. package/dist/initApplication.d.ts.map +1 -1
  25. package/dist/initApplication.js +2 -1
  26. package/dist/internal/getCorrectLocale.d.ts.map +1 -1
  27. package/dist/internal/getCorrectLocale.js +10 -1
  28. package/dist/internal/types.d.ts +0 -24
  29. package/dist/internal/types.d.ts.map +1 -1
  30. package/dist/isBeforeNow.d.ts +1 -1
  31. package/dist/isBeforeNow.d.ts.map +1 -1
  32. package/dist/isBeforeNow.js +1 -3
  33. package/dist/isToday.d.ts +1 -1
  34. package/dist/isToday.d.ts.map +1 -1
  35. package/dist/isToday.js +1 -4
  36. package/package.json +2 -2
  37. package/src/formatDate.ts +2 -4
  38. package/src/formatDateTime.ts +2 -4
  39. package/src/formatFullDate.ts +1 -3
  40. package/src/formatHour.ts +2 -4
  41. package/src/formatMonth.ts +2 -4
  42. package/src/formatTime.ts +2 -4
  43. package/src/formatWeekday.ts +2 -4
  44. package/src/index.ts +0 -2
  45. package/src/initApplication.ts +3 -2
  46. package/src/internal/getCorrectLocale.ts +13 -1
  47. package/src/internal/types.ts +0 -25
  48. package/src/isBeforeNow.ts +2 -5
  49. package/src/isToday.ts +2 -6
  50. package/dist/getWeather.d.ts +0 -3
  51. package/dist/getWeather.d.ts.map +0 -1
  52. package/dist/getWeather.js +0 -39
  53. package/dist/internal/getCorrectDateTime.d.ts +0 -3
  54. package/dist/internal/getCorrectDateTime.d.ts.map +0 -1
  55. package/dist/internal/getCorrectDateTime.js +0 -14
  56. package/dist/internal/weather.d.ts +0 -27
  57. package/dist/internal/weather.d.ts.map +0 -1
  58. package/dist/internal/weather.js +0 -69
  59. package/src/getWeather.ts +0 -41
  60. package/src/internal/getCorrectDateTime.ts +0 -19
  61. package/src/internal/weather.ts +0 -117
@@ -1,3 +1,3 @@
1
1
  import type { DateTime } from 'luxon';
2
- export default function (date: DateTime | string | null, locale?: string): string;
2
+ export default function (date: DateTime, locale?: string): string;
3
3
  //# sourceMappingURL=formatDate.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"formatDate.d.ts","sourceRoot":"","sources":["../src/formatDate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAIrC,MAAM,CAAC,OAAO,WAAW,IAAI,EAAE,QAAQ,GAAC,MAAM,GAAC,IAAI,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAS5E"}
1
+ {"version":3,"file":"formatDate.d.ts","sourceRoot":"","sources":["../src/formatDate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAGrC,MAAM,CAAC,OAAO,WAAW,IAAI,EAAE,QAAQ,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAQhE"}
@@ -1,9 +1,7 @@
1
1
  import getCorrectLocale from './internal/getCorrectLocale';
2
- import getCorrectDateTime from './internal/getCorrectDateTime';
3
2
  export default function (date, locale) {
4
3
  const localization = getCorrectLocale(locale);
5
- const dateTime = getCorrectDateTime(date);
6
- return dateTime.setLocale(localization).toLocaleString({
4
+ return date.setLocale(localization).toLocaleString({
7
5
  year: "numeric",
8
6
  month: "long",
9
7
  day: "numeric"
@@ -1,3 +1,3 @@
1
1
  import type { DateTime } from 'luxon';
2
- export default function (date: DateTime | string | null, locale?: string): string;
2
+ export default function (date: DateTime, locale?: string): string;
3
3
  //# sourceMappingURL=formatDateTime.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"formatDateTime.d.ts","sourceRoot":"","sources":["../src/formatDateTime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAIrC,MAAM,CAAC,OAAO,WAAW,IAAI,EAAE,QAAQ,GAAC,MAAM,GAAC,IAAI,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAW5E"}
1
+ {"version":3,"file":"formatDateTime.d.ts","sourceRoot":"","sources":["../src/formatDateTime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAGrC,MAAM,CAAC,OAAO,WAAW,IAAI,EAAE,QAAQ,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAUhE"}
@@ -1,9 +1,7 @@
1
1
  import getCorrectLocale from './internal/getCorrectLocale';
2
- import getCorrectDateTime from './internal/getCorrectDateTime';
3
2
  export default function (date, locale) {
4
3
  const localization = getCorrectLocale(locale);
5
- const dateTime = getCorrectDateTime(date);
6
- return dateTime.setLocale(localization).toLocaleString({
4
+ return date.setLocale(localization).toLocaleString({
7
5
  day: "numeric",
8
6
  weekday: "long",
9
7
  month: "long",
@@ -1 +1 @@
1
- {"version":3,"file":"formatFullDate.d.ts","sourceRoot":"","sources":["../src/formatFullDate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAIrC,MAAM,CAAC,OAAO,WAAW,IAAI,EAAE,QAAQ,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAShE"}
1
+ {"version":3,"file":"formatFullDate.d.ts","sourceRoot":"","sources":["../src/formatFullDate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAGrC,MAAM,CAAC,OAAO,WAAW,IAAI,EAAE,QAAQ,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAQhE"}
@@ -1,9 +1,7 @@
1
1
  import getCorrectLocale from './internal/getCorrectLocale';
2
- import getCorrectDateTime from './internal/getCorrectDateTime';
3
2
  export default function (date, locale) {
4
3
  const localization = getCorrectLocale(locale);
5
- const dateTime = getCorrectDateTime(date);
6
- return dateTime.setLocale(localization).toLocaleString({
4
+ return date.setLocale(localization).toLocaleString({
7
5
  day: "numeric",
8
6
  weekday: "long",
9
7
  month: "long"
@@ -1,3 +1,3 @@
1
1
  import type { DateTime } from 'luxon';
2
- export default function (date: DateTime | string | null, locale?: string): string;
2
+ export default function (date: DateTime, locale?: string): string;
3
3
  //# sourceMappingURL=formatHour.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"formatHour.d.ts","sourceRoot":"","sources":["../src/formatHour.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAIrC,MAAM,CAAC,OAAO,WAAW,IAAI,EAAE,QAAQ,GAAC,MAAM,GAAC,IAAI,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAO5E"}
1
+ {"version":3,"file":"formatHour.d.ts","sourceRoot":"","sources":["../src/formatHour.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAGrC,MAAM,CAAC,OAAO,WAAW,IAAI,EAAE,QAAQ,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAMhE"}
@@ -1,9 +1,7 @@
1
1
  import getCorrectLocale from './internal/getCorrectLocale';
2
- import getCorrectDateTime from './internal/getCorrectDateTime';
3
2
  export default function (date, locale) {
4
- const dateTime = getCorrectDateTime(date);
5
3
  const localization = getCorrectLocale(locale);
6
- return dateTime.setLocale(localization).toLocaleString({
4
+ return date.setLocale(localization).toLocaleString({
7
5
  hour: "2-digit"
8
6
  });
9
7
  }
@@ -1,3 +1,3 @@
1
1
  import type { DateTime } from 'luxon';
2
- export default function (date: DateTime | string | null, isLong?: boolean, locale?: string): string;
2
+ export default function (date: DateTime, isLong?: boolean, locale?: string): string;
3
3
  //# sourceMappingURL=formatMonth.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"formatMonth.d.ts","sourceRoot":"","sources":["../src/formatMonth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAIrC,MAAM,CAAC,OAAO,WAAW,IAAI,EAAE,QAAQ,GAAC,MAAM,GAAC,IAAI,EAAE,MAAM,GAAE,OAAc,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAOpG"}
1
+ {"version":3,"file":"formatMonth.d.ts","sourceRoot":"","sources":["../src/formatMonth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAGrC,MAAM,CAAC,OAAO,WAAW,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAE,OAAc,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAMxF"}
@@ -1,9 +1,7 @@
1
1
  import getCorrectLocale from './internal/getCorrectLocale';
2
- import getCorrectDateTime from './internal/getCorrectDateTime';
3
2
  export default function (date, isLong = true, locale) {
4
3
  const localization = getCorrectLocale(locale);
5
- const dateTime = getCorrectDateTime(date);
6
- return dateTime.setLocale(localization).toLocaleString({
4
+ return date.setLocale(localization).toLocaleString({
7
5
  month: isLong ? "long" : "short",
8
6
  });
9
7
  }
@@ -1,3 +1,3 @@
1
1
  import type { DateTime } from 'luxon';
2
- export default function (date: DateTime | string | null, locale?: string): string;
2
+ export default function (date: DateTime, locale?: string): string;
3
3
  //# sourceMappingURL=formatTime.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"formatTime.d.ts","sourceRoot":"","sources":["../src/formatTime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAIrC,MAAM,CAAC,OAAO,WAAW,IAAI,EAAE,QAAQ,GAAC,MAAM,GAAC,IAAI,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAQ5E"}
1
+ {"version":3,"file":"formatTime.d.ts","sourceRoot":"","sources":["../src/formatTime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAGrC,MAAM,CAAC,OAAO,WAAW,IAAI,EAAE,QAAQ,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAOhE"}
@@ -1,9 +1,7 @@
1
1
  import getCorrectLocale from './internal/getCorrectLocale';
2
- import getCorrectDateTime from './internal/getCorrectDateTime';
3
2
  export default function (date, locale) {
4
3
  const localization = getCorrectLocale(locale);
5
- const dateTime = getCorrectDateTime(date);
6
- return dateTime.setLocale(localization).toLocaleString({
4
+ return date.setLocale(localization).toLocaleString({
7
5
  hour: "2-digit",
8
6
  minute: "2-digit"
9
7
  });
@@ -1,3 +1,3 @@
1
1
  import type { DateTime } from 'luxon';
2
- export default function (date: DateTime | string | null, isLong?: boolean, locale?: string): string;
2
+ export default function (date: DateTime, isLong?: boolean, locale?: string): string;
3
3
  //# sourceMappingURL=formatWeekday.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"formatWeekday.d.ts","sourceRoot":"","sources":["../src/formatWeekday.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAIrC,MAAM,CAAC,OAAO,WAAW,IAAI,EAAE,QAAQ,GAAC,MAAM,GAAC,IAAI,EAAE,MAAM,GAAE,OAAc,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAOpG"}
1
+ {"version":3,"file":"formatWeekday.d.ts","sourceRoot":"","sources":["../src/formatWeekday.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAGrC,MAAM,CAAC,OAAO,WAAW,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAE,OAAc,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAMxF"}
@@ -1,9 +1,7 @@
1
1
  import getCorrectLocale from './internal/getCorrectLocale';
2
- import getCorrectDateTime from './internal/getCorrectDateTime';
3
2
  export default function (date, isLong = true, locale) {
4
3
  const localization = getCorrectLocale(locale);
5
- const dateTime = getCorrectDateTime(date);
6
- return dateTime.setLocale(localization).toLocaleString({
4
+ return date.setLocale(localization).toLocaleString({
7
5
  weekday: isLong ? "long" : "short",
8
6
  });
9
7
  }
package/dist/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- export type { Weather, WeatherItem } from './internal/weather';
2
1
  export { getLanguage, getLanguages } from './internal/localization';
3
2
  export { default as containsRoutePrefix } from './containsRoutePrefix';
4
3
  export { default as disableZoom } from './disableZoom';
@@ -17,7 +16,6 @@ export { default as formatPercentage } from './formatPercentage';
17
16
  export { default as formatTime } from './formatTime';
18
17
  export { default as formatWeekday } from './formatWeekday';
19
18
  export { default as getToday } from './getToday';
20
- export { default as getWeather } from './getWeather';
21
19
  export { default as hasCurrentRoute } from './hasCurrentRoute';
22
20
  export { default as initApplication } from './initApplication';
23
21
  export { default as isBeforeNow } from './isBeforeNow';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.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entage';
16
16
  export { default as formatTime } from './formatTime';
17
17
  export { default as formatWeekday } from './formatWeekday';
18
18
  export { default as getToday } from './getToday';
19
- export { default as getWeather } from './getWeather';
20
19
  export { default as hasCurrentRoute } from './hasCurrentRoute';
21
20
  export { default as initApplication } from './initApplication';
22
21
  export { default as isBeforeNow } from './isBeforeNow';
@@ -1 +1 @@
1
- {"version":3,"file":"initApplication.d.ts","sourceRoot":"","sources":["../src/initApplication.ts"],"names":[],"mappings":"AAGA,KAAK,iBAAiB,GAAG;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC5B,CAAA;AAED,MAAM,CAAC,OAAO,WAAW,MAAM,EAAE,iBAAiB,GAAG,IAAI,CAQxD"}
1
+ {"version":3,"file":"initApplication.d.ts","sourceRoot":"","sources":["../src/initApplication.ts"],"names":[],"mappings":"AAIA,KAAK,iBAAiB,GAAG;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC5B,CAAC;AAEF,MAAM,CAAC,OAAO,WAAW,MAAM,EAAE,iBAAiB,GAAG,IAAI,CAQxD"}
@@ -1,7 +1,8 @@
1
1
  import disableZoom from './disableZoom';
2
2
  import useDarkTheme from './useDarkTheme';
3
+ import getCorrectLocale from './internal/getCorrectLocale';
3
4
  export default function (config) {
4
- document.documentElement.setAttribute("lang", config.locale ?? "en");
5
+ document.documentElement.setAttribute("lang", getCorrectLocale(config.locale));
5
6
  useDarkTheme(config.isDarkTheme ?? false);
6
7
  if (config.isZoomDisabled) {
7
8
  disableZoom();
@@ -1 +1 @@
1
- {"version":3,"file":"getCorrectLocale.d.ts","sourceRoot":"","sources":["../../src/internal/getCorrectLocale.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,WAAW,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAEhD"}
1
+ {"version":3,"file":"getCorrectLocale.d.ts","sourceRoot":"","sources":["../../src/internal/getCorrectLocale.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,WAAW,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAchD"}
@@ -1,3 +1,12 @@
1
1
  export default function (locale) {
2
- return locale ?? document.documentElement.lang ?? "en";
2
+ if (locale) {
3
+ return locale;
4
+ }
5
+ if (typeof document !== "undefined" && document.documentElement?.lang) {
6
+ return document.documentElement.lang;
7
+ }
8
+ if (typeof navigator !== "undefined" && navigator.language) {
9
+ return navigator.language;
10
+ }
11
+ return "en";
3
12
  }
@@ -1,27 +1,3 @@
1
- export type OpenMeteoResponse = {
2
- current: {
3
- time: string;
4
- weather_code: number;
5
- temperature_2m: number;
6
- temperature_2m_min: number;
7
- temperature_2m_max: number;
8
- };
9
- hourly: {
10
- time: string[];
11
- weather_code: number[];
12
- temperature_2m: number[];
13
- temperature_2m_min: number[];
14
- temperature_2m_max: number[];
15
- };
16
- daily: {
17
- time: string[];
18
- sunrise: string[];
19
- sunset: string[];
20
- weather_code: number[];
21
- temperature_2m_min: number[];
22
- temperature_2m_max: number[];
23
- };
24
- };
25
1
  export type TranslateExists = (key: string) => boolean;
26
2
  export type Translate = (key: string, params?: Record<string, unknown> | (string | number)[]) => string;
27
3
  export type Route = {
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/internal/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,iBAAiB,GAAG;IAC5B,OAAO,EAAE;QACL,IAAI,EAAE,MAAM,CAAC;QACb,YAAY,EAAE,MAAM,CAAC;QACrB,cAAc,EAAE,MAAM,CAAC;QACvB,kBAAkB,EAAE,MAAM,CAAC;QAC3B,kBAAkB,EAAE,MAAM,CAAC;KAC9B,CAAC;IACF,MAAM,EAAE;QACJ,IAAI,EAAE,MAAM,EAAE,CAAC;QACf,YAAY,EAAE,MAAM,E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AAM,KAAK,GAAG;IAChB,IAAI,EAAE,MAAM,GAAC,MAAM,GAAC,SAAS,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,IAAI,GAAG;IACf,CAAC,EAAE,SAAS,CAAC;IACb,EAAE,EAAE,SAAS,CAAC;IACd,EAAE,EAAE,eAAe,CAAC;IACpB,GAAG,EAAE,eAAe,CAAC;CACxB,CAAC"}
@@ -1,3 +1,3 @@
1
1
  import { DateTime } from 'luxon';
2
- export default function (date: DateTime | string | null): boolean;
2
+ export default function (date: DateTime): boolean;
3
3
  //# sourceMappingURL=isBeforeNow.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"isBeforeNow.d.ts","sourceRoot":"","sources":["../src/isBeforeNow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAGhC,MAAM,CAAC,OAAO,WAAW,IAAI,EAAE,QAAQ,GAAC,MAAM,GAAC,IAAI,GAAG,OAAO,CAI5D"}
1
+ {"version":3,"file":"isBeforeNow.d.ts","sourceRoot":"","sources":["../src/isBeforeNow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEhC,MAAM,CAAC,OAAO,WAAW,IAAI,EAAE,QAAQ,GAAG,OAAO,CAEhD"}
@@ -1,6 +1,4 @@
1
1
  import { DateTime } from 'luxon';
2
- import getCorrectDateTime from './internal/getCorrectDateTime';
3
2
  export default function (date) {
4
- const dateTime = getCorrectDateTime(date);
5
- return dateTime.toMillis() < DateTime.now().toMillis();
3
+ return date.toMillis() < DateTime.now().toMillis();
6
4
  }
package/dist/isToday.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  import type { DateTime } from 'luxon';
2
- export default function (dateTime: DateTime | string | null, today: DateTime | string | null): boolean;
2
+ export default function (dateTime: DateTime, today: DateTime): boolean;
3
3
  //# sourceMappingURL=isToday.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"isToday.d.ts","sourceRoot":"","sources":["../src/isToday.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAGrC,MAAM,CAAC,OAAO,WAAW,QAAQ,EAAE,QAAQ,GAAC,MAAM,GAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,GAAC,MAAM,GAAC,IAAI,GAAG,OAAO,CAK7F"}
1
+ {"version":3,"file":"isToday.d.ts","sourceRoot":"","sources":["../src/isToday.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAErC,MAAM,CAAC,OAAO,WAAW,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,GAAG,OAAO,CAErE"}
package/dist/isToday.js CHANGED
@@ -1,6 +1,3 @@
1
- import getCorrectDateTime from './internal/getCorrectDateTime';
2
1
  export default function (dateTime, today) {
3
- const correctDateTime = getCorrectDateTime(dateTime);
4
- const correctToday = getCorrectDateTime(today);
5
- return correctDateTime.hasSame(correctToday, "day");
2
+ return dateTime.hasSame(today, "day");
6
3
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@almighty-shogun/utils",
3
3
  "description": "A small package that contains common utilities used in all my projects.",
4
- "version": "1.10.0",
4
+ "version": "1.11.0",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "scripts": {
@@ -18,7 +18,7 @@
18
18
  },
19
19
  "repository": {
20
20
  "type": "git",
21
- "url": "git+https://github.com/Almighty-Shogun/packages.git",
21
+ "url": "git+https://github.com/Almighty-Shogun/node-packages.git",
22
22
  "directory": "packages/utils"
23
23
  },
24
24
  "main": "./dist/index.js",
package/src/formatDate.ts CHANGED
@@ -1,12 +1,10 @@
1
1
  import type { DateTime } from 'luxon'
2
2
  import getCorrectLocale from './internal/getCorrectLocale'
3
- import getCorrectDateTime from './internal/getCorrectDateTime'
4
3
 
5
- export default function (date: DateTime|string|null, locale?: string): string {
4
+ export default function (date: DateTime, locale?: string): string {
6
5
  const localization = getCorrectLocale(locale);
7
- const dateTime = getCorrectDateTime(date);
8
6
 
9
- return dateTime.setLocale(localization).toLocaleString({
7
+ return date.setLocale(localization).toLocaleString({
10
8
  year: "numeric",
11
9
  month: "long",
12
10
  day: "numeric"
@@ -1,12 +1,10 @@
1
1
  import type { DateTime } from 'luxon'
2
2
  import getCorrectLocale from './internal/getCorrectLocale'
3
- import getCorrectDateTime from './internal/getCorrectDateTime'
4
3
 
5
- export default function (date: DateTime|string|null, locale?: string): string {
4
+ export default function (date: DateTime, locale?: string): string {
6
5
  const localization = getCorrectLocale(locale);
7
- const dateTime = getCorrectDateTime(date);
8
6
 
9
- return dateTime.setLocale(localization).toLocaleString({
7
+ return date.setLocale(localization).toLocaleString({
10
8
  day: "numeric",
11
9
  weekday: "long",
12
10
  month: "long",
@@ -1,12 +1,10 @@
1
1
  import type { DateTime } from 'luxon'
2
2
  import getCorrectLocale from './internal/getCorrectLocale'
3
- import getCorrectDateTime from './internal/getCorrectDateTime'
4
3
 
5
4
  export default function (date: DateTime, locale?: string): string {
6
5
  const localization = getCorrectLocale(locale);
7
- const dateTime = getCorrectDateTime(date);
8
6
 
9
- return dateTime.setLocale(localization).toLocaleString({
7
+ return date.setLocale(localization).toLocaleString({
10
8
  day: "numeric",
11
9
  weekday: "long",
12
10
  month: "long"
package/src/formatHour.ts CHANGED
@@ -1,12 +1,10 @@
1
1
  import type { DateTime } from 'luxon'
2
2
  import getCorrectLocale from './internal/getCorrectLocale'
3
- import getCorrectDateTime from './internal/getCorrectDateTime'
4
3
 
5
- export default function (date: DateTime|string|null, locale?: string): string {
6
- const dateTime = getCorrectDateTime(date);
4
+ export default function (date: DateTime, locale?: string): string {
7
5
  const localization = getCorrectLocale(locale);
8
6
 
9
- return dateTime.setLocale(localization).toLocaleString({
7
+ return date.setLocale(localization).toLocaleString({
10
8
  hour: "2-digit"
11
9
  });
12
10
  }
@@ -1,12 +1,10 @@
1
1
  import type { DateTime } from 'luxon'
2
2
  import getCorrectLocale from './internal/getCorrectLocale'
3
- import getCorrectDateTime from './internal/getCorrectDateTime'
4
3
 
5
- export default function (date: DateTime|string|null, isLong: boolean = true, locale?: string): string {
4
+ export default function (date: DateTime, isLong: boolean = true, locale?: string): string {
6
5
  const localization = getCorrectLocale(locale);
7
- const dateTime = getCorrectDateTime(date);
8
6
 
9
- return dateTime.setLocale(localization).toLocaleString({
7
+ return date.setLocale(localization).toLocaleString({
10
8
  month: isLong ? "long" : "short",
11
9
  });
12
10
  }
package/src/formatTime.ts CHANGED
@@ -1,12 +1,10 @@
1
1
  import type { DateTime } from 'luxon'
2
2
  import getCorrectLocale from './internal/getCorrectLocale'
3
- import getCorrectDateTime from './internal/getCorrectDateTime'
4
3
 
5
- export default function (date: DateTime|string|null, locale?: string): string {
4
+ export default function (date: DateTime, locale?: string): string {
6
5
  const localization = getCorrectLocale(locale);
7
- const dateTime = getCorrectDateTime(date);
8
6
 
9
- return dateTime.setLocale(localization).toLocaleString({
7
+ return date.setLocale(localization).toLocaleString({
10
8
  hour: "2-digit",
11
9
  minute: "2-digit"
12
10
  });
@@ -1,12 +1,10 @@
1
1
  import type { DateTime } from 'luxon'
2
2
  import getCorrectLocale from './internal/getCorrectLocale'
3
- import getCorrectDateTime from './internal/getCorrectDateTime'
4
3
 
5
- export default function (date: DateTime|string|null, isLong: boolean = true, locale?: string): string {
4
+ export default function (date: DateTime, isLong: boolean = true, locale?: string): string {
6
5
  const localization = getCorrectLocale(locale);
7
- const dateTime = getCorrectDateTime(date);
8
6
 
9
- return dateTime.setLocale(localization).toLocaleString({
7
+ return date.setLocale(localization).toLocaleString({
10
8
  weekday: isLong ? "long" : "short",
11
9
  });
12
10
  }
package/src/index.ts CHANGED
@@ -1,4 +1,3 @@
1
- export type { Weather, WeatherItem } from './internal/weather'
2
1
  export { getLanguage, getLanguages } from './internal/localization'
3
2
 
4
3
  export { default as containsRoutePrefix } from './containsRoutePrefix'
@@ -18,7 +17,6 @@ export { default as formatPercentage } from './formatPercentage'
18
17
  export { default as formatTime } from './formatTime'
19
18
  export { default as formatWeekday } from './formatWeekday'
20
19
  export { default as getToday } from './getToday'
21
- export { default as getWeather } from './getWeather'
22
20
  export { default as hasCurrentRoute } from './hasCurrentRoute'
23
21
  export { default as initApplication } from './initApplication'
24
22
  export { default as isBeforeNow } from './isBeforeNow'
@@ -1,14 +1,15 @@
1
1
  import disableZoom from './disableZoom'
2
2
  import useDarkTheme from './useDarkTheme'
3
+ import getCorrectLocale from './internal/getCorrectLocale'
3
4
 
4
5
  type ApplicationConfig = {
5
6
  locale?: string;
6
7
  isDarkTheme?: boolean;
7
8
  isZoomDisabled?: boolean;
8
- }
9
+ };
9
10
 
10
11
  export default function (config: ApplicationConfig): void {
11
- document.documentElement.setAttribute("lang", config.locale ?? "en");
12
+ document.documentElement.setAttribute("lang", getCorrectLocale(config.locale));
12
13
 
13
14
  useDarkTheme(config.isDarkTheme ?? false);
14
15
 
@@ -1,3 +1,15 @@
1
1
  export default function (locale?: string): string {
2
- return locale ?? document.documentElement.lang ?? "en";
2
+ if (locale) {
3
+ return locale;
4
+ }
5
+
6
+ if (typeof document !== "undefined" && document.documentElement?.lang) {
7
+ return document.documentElement.lang;
8
+ }
9
+
10
+ if (typeof navigator !== "undefined" && navigator.language) {
11
+ return navigator.language;
12
+ }
13
+
14
+ return "en";
3
15
  }
@@ -1,28 +1,3 @@
1
- export type OpenMeteoResponse = {
2
- current: {
3
- time: string;
4
- weather_code: number;
5
- temperature_2m: number;
6
- temperature_2m_min: number;
7
- temperature_2m_max: number;
8
- };
9
- hourly: {
10
- time: string[];
11
- weather_code: number[];
12
- temperature_2m: number[];
13
- temperature_2m_min: number[];
14
- temperature_2m_max: number[];
15
- };
16
- daily: {
17
- time: string[];
18
- sunrise: string[];
19
- sunset: string[];
20
- weather_code: number[];
21
- temperature_2m_min: number[];
22
- temperature_2m_max: number[];
23
- }
24
- };
25
-
26
1
  export type TranslateExists = (key: string) => boolean;
27
2
  export type Translate = (key: string, params?: Record<string, unknown> | (string | number)[]) => string;
28
3
 
@@ -1,8 +1,5 @@
1
1
  import { DateTime } from 'luxon'
2
- import getCorrectDateTime from './internal/getCorrectDateTime'
3
2
 
4
- export default function (date: DateTime|string|null): boolean {
5
- const dateTime = getCorrectDateTime(date);
6
-
7
- return dateTime.toMillis() < DateTime.now().toMillis();
3
+ export default function (date: DateTime): boolean {
4
+ return date.toMillis() < DateTime.now().toMillis();
8
5
  }
package/src/isToday.ts CHANGED
@@ -1,9 +1,5 @@
1
1
  import type { DateTime } from 'luxon'
2
- import getCorrectDateTime from './internal/getCorrectDateTime'
3
2
 
4
- export default function (dateTime: DateTime|string|null, today: DateTime|string|null): boolean {
5
- const correctDateTime = getCorrectDateTime(dateTime);
6
- const correctToday = getCorrectDateTime(today);
7
-
8
- return correctDateTime.hasSame(correctToday, "day");
3
+ export default function (dateTime: DateTime, today: DateTime): boolean {
4
+ return dateTime.hasSame(today, "day");
9
5
  }
@@ -1,3 +0,0 @@
1
- import { type Weather } from './internal/weather';
2
- export default function (latitude: number, longitude: number): Promise<Weather>;
3
- //# sourceMappingURL=getWeather.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getWeather.d.ts","sourceRoot":"","sources":["../src/getWeather.ts"],"names":[],"mappings":"AACA,OAAO,EAAiC,KAAK,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAEhF,yBAA+B,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAqCpF"}
@@ -1,39 +0,0 @@
1
- import { DateTime } from 'luxon';
2
- import { callOpenMeteo, getWeatherIcon } from './internal/weather';
3
- export default async function (latitude, longitude) {
4
- const { current, daily, hourly } = await callOpenMeteo(latitude, longitude);
5
- return {
6
- current: {
7
- time: current.time,
8
- temperature: {
9
- current: current.temperature_2m,
10
- min: current.temperature_2m_min,
11
- max: current.temperature_2m_max
12
- },
13
- weatherCode: current.weather_code,
14
- icon: getWeatherIcon(current.weather_code, [current.time, daily.sunrise[0], daily.sunset[0]])
15
- },
16
- today: {
17
- time: daily.time[0],
18
- temperature: {
19
- current: current.temperature_2m,
20
- min: daily.temperature_2m_min[0],
21
- max: daily.temperature_2m_max[0]
22
- },
23
- weatherCode: daily.weather_code[0],
24
- icon: getWeatherIcon(daily.weather_code[0], [daily.time[0], daily.sunrise[0], daily.sunset[0]]),
25
- sunrise: daily.sunrise[0],
26
- sunset: daily.sunset[0]
27
- },
28
- hours: hourly.time.map((time, index) => ({
29
- time,
30
- temperature: {
31
- current: hourly.temperature_2m[index],
32
- min: hourly.temperature_2m_min[index],
33
- max: hourly.temperature_2m_max[index]
34
- },
35
- weatherCode: hourly.weather_code[index],
36
- icon: getWeatherIcon(hourly.weather_code[index], [time, daily.sunrise[0], daily.sunset[0]])
37
- })).filter(hour => DateTime.fromISO(hour.time) > DateTime.fromISO(current.time).startOf("hour"))
38
- };
39
- }
@@ -1,3 +0,0 @@
1
- import { DateTime } from 'luxon';
2
- export default function (date: DateTime | string | null): DateTime;
3
- //# sourceMappingURL=getCorrectDateTime.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getCorrectDateTime.d.ts","sourceRoot":"","sources":["../../src/internal/getCorrectDateTime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEhC,MAAM,CAAC,OAAO,WAAW,IAAI,EAAE,QAAQ,GAAC,MAAM,GAAC,IAAI,GAAG,QAAQ,CAgB7D"}
@@ -1,14 +0,0 @@
1
- import { DateTime } from 'luxon';
2
- export default function (date) {
3
- if (!date) {
4
- return DateTime.now();
5
- }
6
- if (date instanceof DateTime) {
7
- return date;
8
- }
9
- const isoDate = DateTime.fromISO(date);
10
- if (isoDate.isValid) {
11
- return isoDate;
12
- }
13
- return DateTime.fromFormat(date, "yyyy-MM-dd");
14
- }
@@ -1,27 +0,0 @@
1
- import type { OpenMeteoResponse } from './types';
2
- type WeatherTemperature = {
3
- current: number;
4
- min: number;
5
- max: number;
6
- };
7
- export type WeatherItem = {
8
- time: string;
9
- temperature: WeatherTemperature;
10
- weatherCode: number;
11
- icon: string;
12
- };
13
- export type Weather = {
14
- current: WeatherItem;
15
- today: WeatherItem & {
16
- sunrise: string;
17
- sunset: string;
18
- };
19
- hours: WeatherItem[];
20
- };
21
- type WeatherIcon = [day: string, night: string];
22
- export type WeatherCode = keyof typeof weatherCodeMap;
23
- declare const weatherCodeMap: Record<number, WeatherIcon>;
24
- export declare function callOpenMeteo(latitude: number, longitude: number): Promise<OpenMeteoResponse>;
25
- export declare function getWeatherIcon(code: number, timeStrings: string[]): string;
26
- export {};
27
- //# sourceMappingURL=weather.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"weather.d.ts","sourceRoot":"","sources":["../../src/internal/weather.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAEhD,KAAK,kBAAkB,GAAG;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,kBAAkB,CAAC;IAChC,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IAClB,OAAO,EAAE,WAAW,CAAC;IACrB,KAAK,EAAE,WAAW,GAAG;QACjB,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,KAAK,EAAE,WAAW,EAAE,CAAC;CACxB,CAAC;AAEF,KAAK,WAAW,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;AAChD,MAAM,MAAM,WAAW,GAAG,MAAM,OAAO,cAAc,CAAC;AAEtD,QAAA,MAAM,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAoD/C,CAAA;AAED,wBAAsB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAcnG;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,MAAM,CAkB1E"}
@@ -1,69 +0,0 @@
1
- import { DateTime } from 'luxon';
2
- const weatherCodeMap = {
3
- // 0 = Clear sky
4
- 0: ["images/weather-icons/clear-day", "images/weather-icons/clear-night"],
5
- // 1 = Mainly clear, 2 = Partly cloudy, 3 = Overcast
6
- 1: ["images/weather-icons/partly-cloudy-day", "images/weather-icons/partly-cloudy-night"],
7
- 2: ["images/weather-icons/partly-cloudy-day", "images/weather-icons/partly-cloudy-night"],
8
- 3: ["images/weather-icons/overcast-day", "images/weather-icons/overcast-night"],
9
- // 45 = Fog, 48 = Depositing rime fog
10
- 45: ["images/weather-icons/fog-day", "images/weather-icons/fog-night"],
11
- 48: ["images/weather-icons/overcast-day-fog", "images/weather-icons/overcast-night-fog"],
12
- // 51 = Light drizzle, 53 = Moderate drizzle, 55 = Heavy drizzle
13
- 51: ["images/weather-icons/partly-cloudy-day-drizzle", "images/weather-icons/partly-cloudy-night-drizzle"],
14
- 53: ["images/weather-icons/overcast-day-drizzle", "images/weather-icons/overcast-night-drizzle"],
15
- 55: ["images/weather-icons/extreme-day-drizzle", "images/weather-icons/extreme-night-drizzle"],
16
- // 56 = Light freezing drizzle, 57 = Heavy freezing drizzle
17
- 56: ["images/weather-icons/partly-cloudy-day-sleet", "images/weather-icons/partly-cloudy-night-sleet"],
18
- 57: ["images/weather-icons/extreme-day-sleet", "images/weather-icons/extreme-night-sleet"],
19
- // 61 = Light rain, 63 = Moderate rain, 65 = Heavy rain
20
- 61: ["images/weather-icons/partly-cloudy-day-rain", "images/weather-icons/partly-cloudy-night-rain"],
21
- 63: ["images/weather-icons/overcast-day-rain", "images/weather-icons/overcast-night-rain"],
22
- 65: ["images/weather-icons/extreme-day-rain", "images/weather-icons/extreme-night-rain"],
23
- // 66 = Light freezing rain, 67 = Heavy freezing rain
24
- 66: ["images/weather-icons/partly-cloudy-day-sleet", "images/weather-icons/partly-cloudy-night-sleet"],
25
- 67: ["images/weather-icons/extreme-day-sleet", "images/weather-icons/extreme-night-sleet"],
26
- // 71 = Light snow, 73 = Moderate snow, 75 = Heavy snow
27
- 71: ["images/weather-icons/partly-cloudy-day-snow", "images/weather-icons/partly-cloudy-night-snow"],
28
- 73: ["images/weather-icons/overcast-day-snow", "images/weather-icons/overcast-night-snow"],
29
- 75: ["images/weather-icons/extreme-day-snow", "images/weather-icons/extreme-night-snow"],
30
- // 77 Snow grains
31
- 77: ["images/weather-icons/partly-cloudy-day-snow", "images/weather-icons/partly-cloudy-night-snow"],
32
- // 80 = Light rain showers, 81 = Moderate rain showers, 82 = Heavy rain showers
33
- 80: ["images/weather-icons/partly-cloudy-day-rain", "images/weather-icons/partly-cloudy-night-rain"],
34
- 81: ["images/weather-icons/overcast-day-rain", "images/weather-icons/overcast-night-rain"],
35
- 82: ["images/weather-icons/extreme-day-rain", "images/weather-icons/extreme-night-rain"],
36
- // 85 = Light snow showers, 86 = Heavy snow showers
37
- 85: ["images/weather-icons/partly-cloudy-day-snow", "images/weather-icons/partly-cloudy-night-snow"],
38
- 86: ["images/weather-icons/extreme-day-snow", "images/weather-icons/extreme-night-snow"],
39
- // 95 = Light and moderate thunderstorms, 96 = Light thunderstorms with hail, 99 = Heavy thunderstorms with hail
40
- 95: ["images/weather-icons/thunderstorms-day", "images/weather-icons/thunderstorms-night"],
41
- 96: ["images/weather-icons/thunderstorms-day", "images/weather-icons/thunderstorms-night"],
42
- 99: ["images/weather-icons/thunderstorms-day-extreme", "images/weather-icons/thunderstorms-night-extreme"]
43
- };
44
- export async function callOpenMeteo(latitude, longitude) {
45
- const params = new URLSearchParams({
46
- latitude: latitude.toString(),
47
- longitude: longitude.toString(),
48
- forecast_days: "1",
49
- timezone: "Europe/Amsterdam",
50
- current: "weather_code,temperature_2m,temperature_2m_max,temperature_2m_min",
51
- daily: "temperature_2m_max,temperature_2m_min,weather_code,sunrise,sunset",
52
- hourly: "weather_code,temperature_2m,temperature_2m_max,temperature_2m_min"
53
- });
54
- const response = await fetch(`https://api.open-meteo.com/v1/forecast?${params}`);
55
- return await response.json();
56
- }
57
- export function getWeatherIcon(code, timeStrings) {
58
- const currentTime = DateTime.fromISO(timeStrings[0]);
59
- const sunriseTime = DateTime.fromISO(timeStrings[1]);
60
- const sunsetTime = DateTime.fromISO(timeStrings[2]);
61
- const isDayTime = currentTime >= sunriseTime && currentTime < sunsetTime;
62
- const weatherIcon = weatherCodeMap[code];
63
- if (!weatherIcon) {
64
- console.log(`[Weather] Unknown weather code ${code}`);
65
- return "images/weather-icons/not-available";
66
- }
67
- const [day, night] = weatherIcon;
68
- return isDayTime ? day : night;
69
- }
package/src/getWeather.ts DELETED
@@ -1,41 +0,0 @@
1
- import { DateTime } from 'luxon'
2
- import { callOpenMeteo, getWeatherIcon, type Weather } from './internal/weather'
3
-
4
- export default async function (latitude: number, longitude: number): Promise<Weather> {
5
- const { current, daily, hourly } = await callOpenMeteo(latitude, longitude);
6
-
7
- return {
8
- current: {
9
- time: current.time,
10
- temperature: {
11
- current: current.temperature_2m,
12
- min: current.temperature_2m_min,
13
- max: current.temperature_2m_max
14
- },
15
- weatherCode: current.weather_code,
16
- icon: getWeatherIcon(current.weather_code, [current.time, daily.sunrise[0], daily.sunset[0]])
17
- },
18
- today: {
19
- time: daily.time[0],
20
- temperature: {
21
- current: current.temperature_2m,
22
- min: daily.temperature_2m_min[0],
23
- max: daily.temperature_2m_max[0]
24
- },
25
- weatherCode: daily.weather_code[0],
26
- icon: getWeatherIcon(daily.weather_code[0], [daily.time[0], daily.sunrise[0], daily.sunset[0]]),
27
- sunrise: daily.sunrise[0],
28
- sunset: daily.sunset[0]
29
- },
30
- hours: hourly.time.map((time: string, index: number) => ({
31
- time,
32
- temperature: {
33
- current: hourly.temperature_2m[index],
34
- min: hourly.temperature_2m_min[index],
35
- max: hourly.temperature_2m_max[index]
36
- },
37
- weatherCode: hourly.weather_code[index],
38
- icon: getWeatherIcon(hourly.weather_code[index], [time, daily.sunrise[0], daily.sunset[0]])
39
- })).filter(hour => DateTime.fromISO(hour.time) > DateTime.fromISO(current.time).startOf("hour"))
40
- };
41
- }
@@ -1,19 +0,0 @@
1
- import { DateTime } from 'luxon'
2
-
3
- export default function (date: DateTime|string|null): DateTime {
4
- if (!date) {
5
- return DateTime.now();
6
- }
7
-
8
- if (date instanceof DateTime) {
9
- return date;
10
- }
11
-
12
- const isoDate = DateTime.fromISO(date);
13
-
14
- if (isoDate.isValid) {
15
- return isoDate;
16
- }
17
-
18
- return DateTime.fromFormat(date, "yyyy-MM-dd");
19
- }
@@ -1,117 +0,0 @@
1
- import { DateTime } from 'luxon'
2
- import type { OpenMeteoResponse } from './types'
3
-
4
- type WeatherTemperature = {
5
- current: number;
6
- min: number;
7
- max: number;
8
- };
9
-
10
- export type WeatherItem = {
11
- time: string;
12
- temperature: WeatherTemperature;
13
- weatherCode: number;
14
- icon: string;
15
- };
16
-
17
- export type Weather = {
18
- current: WeatherItem;
19
- today: WeatherItem & {
20
- sunrise: string;
21
- sunset: string;
22
- };
23
- hours: WeatherItem[];
24
- };
25
-
26
- type WeatherIcon = [day: string, night: string];
27
- export type WeatherCode = keyof typeof weatherCodeMap;
28
-
29
- const weatherCodeMap: Record<number, WeatherIcon> = {
30
- // 0 = Clear sky
31
- 0: ["images/weather-icons/clear-day", "images/weather-icons/clear-night"],
32
-
33
- // 1 = Mainly clear, 2 = Partly cloudy, 3 = Overcast
34
- 1: ["images/weather-icons/partly-cloudy-day", "images/weather-icons/partly-cloudy-night"],
35
- 2: ["images/weather-icons/partly-cloudy-day", "images/weather-icons/partly-cloudy-night"],
36
- 3: ["images/weather-icons/overcast-day", "images/weather-icons/overcast-night"],
37
-
38
- // 45 = Fog, 48 = Depositing rime fog
39
- 45: ["images/weather-icons/fog-day", "images/weather-icons/fog-night"],
40
- 48: ["images/weather-icons/overcast-day-fog", "images/weather-icons/overcast-night-fog"],
41
-
42
- // 51 = Light drizzle, 53 = Moderate drizzle, 55 = Heavy drizzle
43
- 51: ["images/weather-icons/partly-cloudy-day-drizzle", "images/weather-icons/partly-cloudy-night-drizzle"],
44
- 53: ["images/weather-icons/overcast-day-drizzle", "images/weather-icons/overcast-night-drizzle"],
45
- 55: ["images/weather-icons/extreme-day-drizzle", "images/weather-icons/extreme-night-drizzle"],
46
-
47
- // 56 = Light freezing drizzle, 57 = Heavy freezing drizzle
48
- 56: ["images/weather-icons/partly-cloudy-day-sleet", "images/weather-icons/partly-cloudy-night-sleet"],
49
- 57: ["images/weather-icons/extreme-day-sleet", "images/weather-icons/extreme-night-sleet"],
50
-
51
- // 61 = Light rain, 63 = Moderate rain, 65 = Heavy rain
52
- 61: ["images/weather-icons/partly-cloudy-day-rain", "images/weather-icons/partly-cloudy-night-rain"],
53
- 63: ["images/weather-icons/overcast-day-rain", "images/weather-icons/overcast-night-rain"],
54
- 65: ["images/weather-icons/extreme-day-rain", "images/weather-icons/extreme-night-rain"],
55
-
56
- // 66 = Light freezing rain, 67 = Heavy freezing rain
57
- 66: ["images/weather-icons/partly-cloudy-day-sleet", "images/weather-icons/partly-cloudy-night-sleet"],
58
- 67: ["images/weather-icons/extreme-day-sleet", "images/weather-icons/extreme-night-sleet"],
59
-
60
- // 71 = Light snow, 73 = Moderate snow, 75 = Heavy snow
61
- 71: ["images/weather-icons/partly-cloudy-day-snow", "images/weather-icons/partly-cloudy-night-snow"],
62
- 73: ["images/weather-icons/overcast-day-snow", "images/weather-icons/overcast-night-snow"],
63
- 75: ["images/weather-icons/extreme-day-snow", "images/weather-icons/extreme-night-snow"],
64
-
65
- // 77 Snow grains
66
- 77: ["images/weather-icons/partly-cloudy-day-snow", "images/weather-icons/partly-cloudy-night-snow"],
67
-
68
- // 80 = Light rain showers, 81 = Moderate rain showers, 82 = Heavy rain showers
69
- 80: ["images/weather-icons/partly-cloudy-day-rain", "images/weather-icons/partly-cloudy-night-rain"],
70
- 81: ["images/weather-icons/overcast-day-rain", "images/weather-icons/overcast-night-rain"],
71
- 82: ["images/weather-icons/extreme-day-rain", "images/weather-icons/extreme-night-rain"],
72
-
73
- // 85 = Light snow showers, 86 = Heavy snow showers
74
- 85: ["images/weather-icons/partly-cloudy-day-snow", "images/weather-icons/partly-cloudy-night-snow"],
75
- 86: ["images/weather-icons/extreme-day-snow", "images/weather-icons/extreme-night-snow"],
76
-
77
- // 95 = Light and moderate thunderstorms, 96 = Light thunderstorms with hail, 99 = Heavy thunderstorms with hail
78
- 95: ["images/weather-icons/thunderstorms-day", "images/weather-icons/thunderstorms-night"],
79
- 96: ["images/weather-icons/thunderstorms-day", "images/weather-icons/thunderstorms-night"],
80
- 99: ["images/weather-icons/thunderstorms-day-extreme", "images/weather-icons/thunderstorms-night-extreme"]
81
- }
82
-
83
- export async function callOpenMeteo(latitude: number, longitude: number): Promise<OpenMeteoResponse> {
84
- const params = new URLSearchParams({
85
- latitude: latitude.toString(),
86
- longitude: longitude.toString(),
87
- forecast_days: "1",
88
- timezone: "Europe/Amsterdam",
89
- current: "weather_code,temperature_2m,temperature_2m_max,temperature_2m_min",
90
- daily: "temperature_2m_max,temperature_2m_min,weather_code,sunrise,sunset",
91
- hourly: "weather_code,temperature_2m,temperature_2m_max,temperature_2m_min"
92
- });
93
-
94
- const response = await fetch(`https://api.open-meteo.com/v1/forecast?${params}`);
95
-
96
- return await response.json();
97
- }
98
-
99
- export function getWeatherIcon(code: number, timeStrings: string[]): string {
100
- const currentTime = DateTime.fromISO(timeStrings[0]);
101
- const sunriseTime = DateTime.fromISO(timeStrings[1]);
102
- const sunsetTime = DateTime.fromISO(timeStrings[2]);
103
-
104
- const isDayTime = currentTime >= sunriseTime && currentTime < sunsetTime;
105
-
106
- const weatherIcon = weatherCodeMap[code];
107
-
108
- if (!weatherIcon) {
109
- console.log(`[Weather] Unknown weather code ${code}`);
110
-
111
- return "images/weather-icons/not-available";
112
- }
113
-
114
- const [day, night] = weatherIcon;
115
-
116
- return isDayTime ? day : night;
117
- }