-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UIDEXP-175: Fix date and time display in Safary (#98)
- Loading branch information
1 parent
82bd57c
commit f59821e
Showing
7 changed files
with
47 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** | ||
This is temp solution because stripes-components was released. | ||
TODO: Update solution during the next release: Move useDateFormatter | ||
and useTimeFormatter to stripes-components and remove them here. | ||
*/ | ||
export const iso8601Timestamp = value => { | ||
let tweakedValue = value; | ||
|
||
if (typeof value !== 'string') { | ||
return tweakedValue; | ||
} | ||
|
||
if (value.length === 28 && (value[23] === '+' || value[23] === '-')) { | ||
tweakedValue = `${value.substring(0, 26)}:${value.substring(26, 28)}`; | ||
} | ||
|
||
return tweakedValue; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { useIntl } from 'react-intl'; | ||
|
||
import { iso8601Timestamp } from './iso8601Timestamp'; | ||
|
||
export const useDateFormatter = () => { | ||
const intl = useIntl(); | ||
|
||
return date => intl.formatDate(iso8601Timestamp(date)); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { useIntl } from 'react-intl'; | ||
|
||
import { iso8601Timestamp } from './iso8601Timestamp'; | ||
|
||
export const useTimeFormatter = () => { | ||
const intl = useIntl(); | ||
|
||
return (time, options) => intl.formatTime(iso8601Timestamp(time), options); | ||
}; |