Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
scratch-www
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
scratch-www
Commits
baba146f
Unverified
Commit
baba146f
authored
Feb 02, 2021
by
chrisgarrity
Committed by
GitHub
Feb 02, 2021
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4895 from chrisgarrity/relative-time-polyfill
Add @formatjs/relativetimeformat-polyfill
parents
f60a8c71
ae2bc24f
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
3666 additions
and
0 deletions
+3666
-0
package-lock.json
package-lock.json
+3641
-0
package.json
package.json
+5
-0
src/lib/format-time.js
src/lib/format-time.js
+2
-0
src/lib/relative-time-polyfill.js
src/lib/relative-time-polyfill.js
+18
-0
No files found.
package-lock.json
View file @
baba146f
This diff is collapsed.
Click to expand it.
package.json
View file @
baba146f
...
@@ -54,6 +54,9 @@
...
@@ -54,6 +54,9 @@
"
scratch-storage
"
:
"
^0.5.1
"
"
scratch-storage
"
:
"
^0.5.1
"
},
},
"devDependencies"
:
{
"devDependencies"
:
{
"
@formatjs/intl-locale
"
:
"
^2.4.13
"
,
"
@formatjs/intl-pluralrules
"
:
"
^4.0.6
"
,
"
@formatjs/intl-relativetimeformat
"
:
"
^8.0.3
"
,
"
ajv
"
:
"
6.4.0
"
,
"
ajv
"
:
"
6.4.0
"
,
"
async
"
:
"
3.1.0
"
,
"
async
"
:
"
3.1.0
"
,
"
autoprefixer
"
:
"
6.3.6
"
,
"
autoprefixer
"
:
"
6.3.6
"
,
...
@@ -91,6 +94,7 @@
...
@@ -91,6 +94,7 @@
"
glob
"
:
"
5.0.15
"
,
"
glob
"
:
"
5.0.15
"
,
"
google-libphonenumber
"
:
"
3.2.6
"
,
"
google-libphonenumber
"
:
"
3.2.6
"
,
"
html-webpack-plugin
"
:
"
2.22.0
"
,
"
html-webpack-plugin
"
:
"
2.22.0
"
,
"
i
"
:
"
^0.3.6
"
,
"
iso-3166-2
"
:
"
0.4.0
"
,
"
iso-3166-2
"
:
"
0.4.0
"
,
"
jest
"
:
"
^23.6.0
"
,
"
jest
"
:
"
^23.6.0
"
,
"
json-loader
"
:
"
0.5.2
"
,
"
json-loader
"
:
"
0.5.2
"
,
...
@@ -108,6 +112,7 @@
...
@@ -108,6 +112,7 @@
"
minilog
"
:
"
2.0.8
"
,
"
minilog
"
:
"
2.0.8
"
,
"
node-dir
"
:
"
0.1.16
"
,
"
node-dir
"
:
"
0.1.16
"
,
"
node-sass
"
:
"
4.14.1
"
,
"
node-sass
"
:
"
4.14.1
"
,
"
npm
"
:
"
^6.14.11
"
,
"
pako
"
:
"
0.2.8
"
,
"
pako
"
:
"
0.2.8
"
,
"
plotly.js
"
:
"
1.47.4
"
,
"
plotly.js
"
:
"
1.47.4
"
,
"
po2icu
"
:
"
0.0.2
"
,
"
po2icu
"
:
"
0.0.2
"
,
...
...
src/lib/format-time.js
View file @
baba146f
// IMPORTANT: any changes to the time algorithm also need to be made in the corresponding
// IMPORTANT: any changes to the time algorithm also need to be made in the corresponding
// scratchr2 file 'lib/format-time.js'
// scratchr2 file 'lib/format-time.js'
require
(
'
./relative-time-polyfill
'
);
/**
/**
Given a timestamp in the future, calculate the largest, closest unit to show.
Given a timestamp in the future, calculate the largest, closest unit to show.
On the high end we stop at hours. e.g. 15 days is still counted in hours not days or weeks.
On the high end we stop at hours. e.g. 15 days is still counted in hours not days or weeks.
...
...
src/lib/relative-time-polyfill.js
0 → 100644
View file @
baba146f
// this file should only be `required` in the format-time
// when Intl.RelativeTimeFormat is not available (Safari < 14), but
// we're not currently able to do the code splitting in www, and it
// is always included. To reduce the amount of data that's loaded limit
// the number of languages loaded to just the top few that are still using
// safari <14. These seven account for most uses.
// relativetimeformat depends on locale which also needs to be polyfilled in
// safari <14
require
(
'
@formatjs/intl-locale/polyfill
'
);
require
(
'
@formatjs/intl-pluralrules
'
);
require
(
'
@formatjs/intl-relativetimeformat/polyfill
'
);
require
(
'
@formatjs/intl-relativetimeformat/locale-data/en
'
);
require
(
'
@formatjs/intl-relativetimeformat/locale-data/ar
'
);
require
(
'
@formatjs/intl-relativetimeformat/locale-data/es
'
);
require
(
'
@formatjs/intl-relativetimeformat/locale-data/fr
'
);
require
(
'
@formatjs/intl-relativetimeformat/locale-data/ja
'
);
require
(
'
@formatjs/intl-relativetimeformat/locale-data/tr
'
);
require
(
'
@formatjs/intl-relativetimeformat/locale-data/zh
'
);
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment