Line endings fixed so that we don't have CRLF in Git. Better now than later.
This commit is contained in:
parent
2fe7f82be3
commit
d482d214d9
69 changed files with 6405 additions and 6405 deletions
148
shared/date.js
148
shared/date.js
|
@ -1,75 +1,75 @@
|
|||
'use strict';
|
||||
|
||||
const moment = require('moment');
|
||||
|
||||
const birthdayYear = 2000;
|
||||
|
||||
const DateFormat = {
|
||||
US: 'us',
|
||||
EU: 'eur',
|
||||
INTL: 'intl'
|
||||
};
|
||||
|
||||
const dateFormatStrings = {
|
||||
'us': 'MM/DD/YYYY',
|
||||
'eur': 'DD/MM/YYYY',
|
||||
'intl': 'YYYY-MM-DD'
|
||||
};
|
||||
|
||||
const birthdayFormatStrings = {
|
||||
'us': 'MM/DD',
|
||||
'eur': 'DD/MM',
|
||||
'intl': 'MM/DD'
|
||||
};
|
||||
|
||||
function parseDate(format, text) {
|
||||
const date = moment.utc(text, dateFormatStrings[format]);
|
||||
|
||||
if (date.isValid()) {
|
||||
return date.toDate();
|
||||
}
|
||||
}
|
||||
|
||||
function parseBirthday(format, text) {
|
||||
const fullDateStr = format === DateFormat.INTL ? birthdayYear + '-' + text : text + '-' + birthdayYear;
|
||||
const date = moment.utc(fullDateStr, dateFormatStrings[format]);
|
||||
|
||||
if (date.isValid()) {
|
||||
return date.toDate();
|
||||
}
|
||||
}
|
||||
|
||||
function formatDate(format, date) {
|
||||
if (date === null) {
|
||||
return '';
|
||||
} else {
|
||||
return moment.utc(date).format(dateFormatStrings[format]);
|
||||
}
|
||||
}
|
||||
|
||||
function formatBirthday(format, date) {
|
||||
if (date === null) {
|
||||
return '';
|
||||
} else {
|
||||
return moment.utc(date).format(birthdayFormatStrings[format]);
|
||||
}
|
||||
}
|
||||
|
||||
function getDateFormatString(format) {
|
||||
return dateFormatStrings[format];
|
||||
}
|
||||
|
||||
function getBirthdayFormatString(format) {
|
||||
return birthdayFormatStrings[format];
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
DateFormat,
|
||||
birthdayYear,
|
||||
parseDate,
|
||||
parseBirthday,
|
||||
formatDate,
|
||||
formatBirthday,
|
||||
getDateFormatString,
|
||||
getBirthdayFormatString
|
||||
'use strict';
|
||||
|
||||
const moment = require('moment');
|
||||
|
||||
const birthdayYear = 2000;
|
||||
|
||||
const DateFormat = {
|
||||
US: 'us',
|
||||
EU: 'eur',
|
||||
INTL: 'intl'
|
||||
};
|
||||
|
||||
const dateFormatStrings = {
|
||||
'us': 'MM/DD/YYYY',
|
||||
'eur': 'DD/MM/YYYY',
|
||||
'intl': 'YYYY-MM-DD'
|
||||
};
|
||||
|
||||
const birthdayFormatStrings = {
|
||||
'us': 'MM/DD',
|
||||
'eur': 'DD/MM',
|
||||
'intl': 'MM/DD'
|
||||
};
|
||||
|
||||
function parseDate(format, text) {
|
||||
const date = moment.utc(text, dateFormatStrings[format]);
|
||||
|
||||
if (date.isValid()) {
|
||||
return date.toDate();
|
||||
}
|
||||
}
|
||||
|
||||
function parseBirthday(format, text) {
|
||||
const fullDateStr = format === DateFormat.INTL ? birthdayYear + '-' + text : text + '-' + birthdayYear;
|
||||
const date = moment.utc(fullDateStr, dateFormatStrings[format]);
|
||||
|
||||
if (date.isValid()) {
|
||||
return date.toDate();
|
||||
}
|
||||
}
|
||||
|
||||
function formatDate(format, date) {
|
||||
if (date === null) {
|
||||
return '';
|
||||
} else {
|
||||
return moment.utc(date).format(dateFormatStrings[format]);
|
||||
}
|
||||
}
|
||||
|
||||
function formatBirthday(format, date) {
|
||||
if (date === null) {
|
||||
return '';
|
||||
} else {
|
||||
return moment.utc(date).format(birthdayFormatStrings[format]);
|
||||
}
|
||||
}
|
||||
|
||||
function getDateFormatString(format) {
|
||||
return dateFormatStrings[format];
|
||||
}
|
||||
|
||||
function getBirthdayFormatString(format) {
|
||||
return birthdayFormatStrings[format];
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
DateFormat,
|
||||
birthdayYear,
|
||||
parseDate,
|
||||
parseBirthday,
|
||||
formatDate,
|
||||
formatBirthday,
|
||||
getDateFormatString,
|
||||
getBirthdayFormatString
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue