update
This commit is contained in:
1 parent
be398bf5ce
commit
f121eff445
38 files changed
+498
-267
No files matched your search
@@ -1,9 +1,23 @@
|
||||
export function shortifyName(name) {
|
||||
let $ = i => i.replace(/^(.).+/, '$1');
|
||||
let [_, first, middle, last] = splitName(name);
|
||||
return `${$(first)}. ${$(middle)}. ${last}`;
|
||||
/**
|
||||
*
|
||||
* "First Middle Last" -> "F. M. Last"
|
||||
*
|
||||
* @param name
|
||||
* @returns {string}
|
||||
*/
|
||||
export function shortName(name) {
|
||||
const f = i => i.replace(/^(.).+/, '$1');
|
||||
const [, first, middle, last] = splitName(name);
|
||||
return `${f(first)}. ${f(middle)}. ${last}`;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* "First Middle Last" -> ["First", "Middle", "Last"]
|
||||
*
|
||||
* @param {string} name
|
||||
* @returns {Array|{index: number, input: string}}
|
||||
*/
|
||||
export function splitName(name) {
|
||||
return /(.+)\s(.+)\s(.+)/.exec(name);
|
||||
}
|
||||
+7
-14
@@ -2,24 +2,17 @@ export const courses = {
|
||||
painting: "Живопись",
|
||||
drawing: "Рисунок",
|
||||
sculpting: "Скульптура",
|
||||
sculpture: "Скульптура",
|
||||
ceramic: "Керамика",
|
||||
ceramics: "Керамика",
|
||||
composition: "Композиция",
|
||||
history: "История искусства",
|
||||
cg: "Комп. графика"
|
||||
};
|
||||
|
||||
export function getCourseByID(id){
|
||||
for(var i=0; i<courses.length; i++){
|
||||
var p = courses[i];
|
||||
if(p.id == id){
|
||||
return p;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
export function getCourseName(id) {
|
||||
const course = Object
|
||||
.entries(courses)
|
||||
.find(([key]) => key === id);
|
||||
return course ? course[1] : null;
|
||||
}
|
||||
|
||||
export function getCourseNameByID(id){
|
||||
var p = getCourseByID(id);
|
||||
if(p) return p.name;
|
||||
else return null;
|
||||
}
|
||||
+17
-11
@@ -1,24 +1,30 @@
|
||||
let tryReplace = (dict, record, map = i=>i) =>
|
||||
record in dict ? map(dict[record]) : record;
|
||||
|
||||
export const autumnMonth = 8;
|
||||
export const springMonth = 0;
|
||||
|
||||
|
||||
export const populate = (dict, map) =>
|
||||
id => tryReplace(dict, id, map);
|
||||
|
||||
export function scheduleDate(schedule){
|
||||
let {period, semester} = schedule;
|
||||
|
||||
let i = semester === 'spring' ? 1 : 0;
|
||||
let year = parseInt(
|
||||
period.split('-')[i]
|
||||
);
|
||||
let year = getPeriod(period)[i];
|
||||
|
||||
return new Date(
|
||||
year,
|
||||
i ? springMonth : autumnMonth ,
|
||||
i ? springMonth : autumnMonth,
|
||||
1
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* f("2012-2015") -> [2012, 2015]
|
||||
* f(["2012", "2015"]) -> [2012, 2015]
|
||||
* f([2012, 2015]) -> [2012, 2015]
|
||||
*
|
||||
* @param i
|
||||
* @returns {*}
|
||||
*/
|
||||
export function getPeriod(i){
|
||||
if (typeof i === 'string') return getPeriod(i.split('-'));
|
||||
|
||||
return i.map(Number);
|
||||
}
|
||||
Reference in new issue
Block a user