More tests

This commit is contained in:
Pieter Vander Vennet 2022-03-15 13:40:23 +01:00
parent 50d383279d
commit 074782c1e0
6 changed files with 52 additions and 56 deletions

View file

@ -220,6 +220,23 @@ export class OH {
}
}
/**
* Converts an OH-syntax rule into an object
*
*
* const rules = OH.ParsePHRule("PH 12:00-17:00")
* rules.mode // => " "
* rules.start // => "12:00"
* rules.end // => "17:00"
*
* OH.ParseRule("PH 12:00-17:00") // => null
* OH.ParseRule("Th[-1] off") // => null
*
* const rules = OH.Parse("24/7");
* rules.length // => 7
* rules[0].startHour // => 0
* OH.ToString(rules) // => "24/7"
*/
public static ParseRule(rule: string): OpeningHour[] {
try {
if (rule.trim() == "24/7") {

View file

@ -43,6 +43,14 @@ export default class Translations {
return new Translation(t, context);
}
/**
* 'Wrap Translation': given an object containing translations OR a string, returns a translation object
*
* const json: any = {"en": "English", "nl": "Nederlands"};
* const translation = Translations.WT(new Translation(json));
* translation.textFor("en") // => "English"
* translation.textFor("nl") // => "Nederlands"
*/
public static WT(s: string | Translation): Translation {
if (s === undefined || s === null) {
return undefined;