@vixoniccom/footbal-score 1.4.6-dev.1 → 1.4.6-dev.3
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.
- package/CHANGELOG.md +4 -0
- package/build/main.js +1 -1
- package/build.zip +0 -0
- package/package.json +1 -1
- package/src/App.tsx +2 -4
- package/src/components/Table/components/Time.tsx +7 -2
- package/src/helpers/getFixture.ts +12 -10
package/build.zip
CHANGED
|
Binary file
|
package/package.json
CHANGED
package/src/App.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useEffect, useRef, useState } from 'react'
|
|
2
2
|
import localforage from 'localforage'
|
|
3
3
|
import { FontLoader, FormattedText, Table } from './components'
|
|
4
|
-
import { getFixture } from './helpers/getFixture'
|
|
4
|
+
import { getFixture, resolvedTimezone } from './helpers/getFixture'
|
|
5
5
|
|
|
6
6
|
export type Props = {
|
|
7
7
|
data: VixonicData
|
|
@@ -142,9 +142,7 @@ export const App: React.FunctionComponent<Props> = ({ data, start }) => {
|
|
|
142
142
|
fetchAndSchedule()
|
|
143
143
|
}, [league])
|
|
144
144
|
|
|
145
|
-
const timezone =
|
|
146
|
-
try { return Intl.DateTimeFormat().resolvedOptions().timeZone } catch { return 'UTC' }
|
|
147
|
-
})()
|
|
145
|
+
const timezone = resolvedTimezone
|
|
148
146
|
|
|
149
147
|
return (
|
|
150
148
|
<>
|
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
import moment from 'moment'
|
|
2
2
|
import React from 'react'
|
|
3
3
|
import { FormattedText } from '../../'
|
|
4
|
+
import { resolvedTimezone } from '../../../helpers/getFixture'
|
|
4
5
|
|
|
5
6
|
interface Props {
|
|
6
7
|
time: number
|
|
7
8
|
parameters: VixonicParameters
|
|
8
9
|
}
|
|
9
10
|
|
|
11
|
+
const MEXICO_TIMEZONES = ['America/Mexico_City', 'America/Cancun', 'America/Merida', 'America/Monterrey', 'America/Matamoros', 'America/Chihuahua', 'America/Ojinaga', 'America/Mazatlan', 'America/Hermosillo', 'America/Tijuana', 'America/Ensenada']
|
|
12
|
+
const offset = MEXICO_TIMEZONES.includes(resolvedTimezone) ? -3600 : 0
|
|
13
|
+
|
|
10
14
|
export const Time: React.FunctionComponent<Props> = ({ time, parameters }) => {
|
|
15
|
+
const adjusted = time + offset
|
|
11
16
|
return (
|
|
12
17
|
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center' }}>
|
|
13
|
-
<FormattedText text={moment.unix(
|
|
14
|
-
<FormattedText text={moment.unix(
|
|
18
|
+
<FormattedText text={moment.unix(adjusted).format('DD-MM')} format={parameters.timeFormat} />
|
|
19
|
+
<FormattedText text={moment.unix(adjusted).format('h:mm a')} format={parameters.timeFormat} />
|
|
15
20
|
</div>
|
|
16
21
|
)
|
|
17
22
|
}
|
|
@@ -11,6 +11,17 @@ const MILLISECONDS_PER_DAY = 24 * 60 * 60 * 1000
|
|
|
11
11
|
|
|
12
12
|
const USE_MOCK = false
|
|
13
13
|
|
|
14
|
+
export const resolvedTimezone = (() => {
|
|
15
|
+
try {
|
|
16
|
+
const tz = Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
17
|
+
console.log(`[football-score] Timezone resolved: ${tz}`)
|
|
18
|
+
return tz
|
|
19
|
+
} catch (error) {
|
|
20
|
+
console.warn('[football-score] Failed to resolve timezone, defaulting to UTC', error)
|
|
21
|
+
return 'UTC'
|
|
22
|
+
}
|
|
23
|
+
})()
|
|
24
|
+
|
|
14
25
|
export const getFixture = async (league: string, yesterday?: boolean, tomorrow?: boolean) => {
|
|
15
26
|
if (USE_MOCK) return mockFixtures
|
|
16
27
|
|
|
@@ -18,16 +29,7 @@ export const getFixture = async (league: string, yesterday?: boolean, tomorrow?:
|
|
|
18
29
|
const year = moment().format('YYYY')
|
|
19
30
|
const from = yesterday ? moment(Date.now() - MILLISECONDS_PER_DAY).format('YYYY-MM-DD') : today
|
|
20
31
|
const to = tomorrow ? moment(Date.now() + MILLISECONDS_PER_DAY).format('YYYY-MM-DD') : today
|
|
21
|
-
const timezone =
|
|
22
|
-
try {
|
|
23
|
-
const tz = Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
24
|
-
console.log(`[football-score] Timezone resolved: ${tz}`)
|
|
25
|
-
return tz
|
|
26
|
-
} catch (error) {
|
|
27
|
-
console.warn('[football-score] Failed to resolve timezone, defaulting to UTC', error)
|
|
28
|
-
return 'UTC'
|
|
29
|
-
}
|
|
30
|
-
})()
|
|
32
|
+
const timezone = resolvedTimezone
|
|
31
33
|
|
|
32
34
|
const options = {
|
|
33
35
|
method: 'GET',
|