Hong-Phuc Bui
2025-01-16 2889de7f0c2d587a17fbd322af57c29e84238620
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
export const DE = Object.freeze({
    weekDays: ["So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"],
    months: [undefined,
        "Januar", "Februar", "März", "April",
        "Mai", "Juni", "Juli", "August",
        "September", "Oktober", "November", "Dezember"],
    firstDayOfWeek: 1
});
 
export const EN = Object.freeze({
    weekDays : ["Sun", "Mon", "Tue", "Wen", "Thu", "Fri", "Sat"],
    months: [undefined,
        "January", "February", "March", "April",
        "May", "June", "July", "August",
        "September", "October", "November", "December"
    ],
    firstDayOfWeek: 0
});
 
export const FR = Object.freeze({
    weekDays : ["dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"],
    months: [undefined,
        "janvier", "février", "mars", "avril",
        "mai", "juin", "juillet", "août",
        "septembre", "octobre", "novembre", "décembre"
    ],
    firstDayOfWeek: 1
});
 
/* Student exercises begin from here */
/**
 * parsers a string, which represents a month in numeral writing, to a number of
 * month, between 1 (january) and 12 (december), or is a name of a month
 * accorded the given language.
 *
 * @param {string|number} month
 * @param {string} language optional case-insensitive Language Code. If a
 * language is not available, then use default language which is EN. (In this case
 * if the input in given language not the same as english word --mostly the case--
 * then it is not recognized.)
 *
 * @return {number} month, which is represented in string.
 *
 * @throws {RangeError} if not a valid month
 *
 * */
export function parseMonth(month, language="EN") {
    // TODO: Exercise: implement this function as the specification in comment!
    // if the implementation is correct, the unit tests will be passed.
    return Number.parseInt(month);
}
 
 
/**
 * parses a string, which represents a year in Gregorian Calendar, to a year in
 * data type number.
 *
 * @param {string} year
 *
 * @return {number} year
 * @throws {RangeError} if the year is not a valid year number in Gregorian Calendar.
 * */
export function parseYear(year) {
    // TODO: Exercise: implement this function as the specification in comment!
    return Number.parseInt(year);
}