This repository has been archived by the owner on Jun 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: time - add support for 'l' and 'D' formatting characters
- Loading branch information
1 parent
4296df1
commit 26a3af3
Showing
11 changed files
with
234 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{ | ||
"$id": "l10n-data", | ||
"defs": { | ||
"l10n-str": { | ||
"type": "string", | ||
"minLength": "1" | ||
}, | ||
"l10n-obj": { | ||
"type": "object", | ||
"additionalProperties": false, | ||
"required": [ | ||
"en" | ||
], | ||
"properties": { | ||
"en": { | ||
"$ref": "l10n-data#/defs/l10n-str" | ||
} | ||
} | ||
} | ||
}, | ||
"type": "object", | ||
"additionalProperties": false, | ||
"required": [ | ||
"days", | ||
"days_short" | ||
], | ||
"properties": { | ||
"days": { | ||
"type": "array", | ||
"minItems": 7, | ||
"maxItems": 7, | ||
"items": { | ||
"$ref": "l10n-data#/defs/l10n-obj" | ||
} | ||
}, | ||
"days_short": { | ||
"$ref": "l10n-data#/properties/days" | ||
} | ||
} | ||
} |
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,45 @@ | ||
{ "days": | ||
[ { "en": "Monday" | ||
} | ||
, | ||
{ "en": "Tuesday" | ||
} | ||
, | ||
{ "en": "Wednesday" | ||
} | ||
, | ||
{ "en": "Thursday" | ||
} | ||
, | ||
{ "en": "Friday" | ||
} | ||
, | ||
{ "en": "Saturday" | ||
} | ||
, | ||
{ "en": "Sunday" | ||
} | ||
] | ||
, "days_short": | ||
[ { "en": "Mon" | ||
} | ||
, | ||
{ "en": "Tue" | ||
} | ||
, | ||
{ "en": "Wed" | ||
} | ||
, | ||
{ "en": "Thu" | ||
} | ||
, | ||
{ "en": "Fri" | ||
} | ||
, | ||
{ "en": "Sat" | ||
} | ||
, | ||
{ "en": "Sun" | ||
} | ||
] | ||
} |
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,22 @@ | ||
const data = require('./l10n-data.json'); | ||
|
||
/** | ||
* Day of the week (e.g. 'Monday') | ||
* @param {lang} l | ||
* @param {weekday} n | ||
* @return {string} | ||
*/ | ||
const day = (l, n) => data.days[n][l]; | ||
|
||
/** | ||
* Day of the week abbreviated (e.g. 'Mon') | ||
* @param {lang} l | ||
* @param {weekday} n | ||
* @return {string} | ||
*/ | ||
const day_short = (l, n) => data.days_short[n][l]; | ||
|
||
module.exports = | ||
{ day | ||
, day_short | ||
}; |
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,15 @@ | ||
const Ajv = require('ajv'); | ||
const test = require('tape'); | ||
|
||
const validate = (new Ajv).compile(require('./l10n-data-schema.json')); | ||
|
||
test('l10n data is consistent', (t) => { | ||
t.plan(1); | ||
const data = require('./dist/utils/l10n-data.json'); | ||
const res = validate(data); | ||
if (res) { | ||
t.pass('l10n data looks ok'); | ||
} else { | ||
t.fail(JSON.stringify(validate.errors[0], null, 2)); | ||
} | ||
}); |
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
Oops, something went wrong.