-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…#5470) * style(datepicker): change Thai 'weekdaysShort' format for look better in datepicker * feat(datepicker): enable to modify date value after input and before format - add 'preinput' method to LocaleData interface (for after input) - add 'postvalue' method to LocaleData interface (for before format) feat(datepicker): add th-be for Thai Buddish caleder for #3893
- Loading branch information
1 parent
8969937
commit 43d0da5
Showing
11 changed files
with
231 additions
and
12 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
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,76 @@ | ||
// tslint:disable:comment-format binary-expression-operand-order max-line-length | ||
// tslint:disable:no-bitwise prefer-template cyclomatic-complexity | ||
// tslint:disable:no-shadowed-variable switch-default prefer-const | ||
// tslint:disable:one-variable-per-declaration newline-before-return | ||
|
||
// moment.js locale configuration | ||
// locale : Thai-Buddhist Era [th-be] | ||
// author : Watcharapol Sanitwong : https://github.com/tumit | ||
|
||
import { LocaleData } from '../locale/locale.class'; | ||
|
||
export const thBeLocale: LocaleData = { | ||
abbr: 'th-be', | ||
months: 'มกราคม_กุมภาพันธ์_มีนาคม_เมษายน_พฤษภาคม_มิถุนายน_กรกฎาคม_สิงหาคม_กันยายน_ตุลาคม_พฤศจิกายน_ธันวาคม'.split('_'), | ||
monthsShort: 'ม.ค._ก.พ._มี.ค._เม.ย._พ.ค._มิ.ย._ก.ค._ส.ค._ก.ย._ต.ค._พ.ย._ธ.ค.'.split('_'), | ||
monthsParseExact: true, | ||
weekdays: 'อาทิตย์_จันทร์_อังคาร_พุธ_พฤหัสบดี_ศุกร์_เสาร์'.split('_'), | ||
weekdaysShort: 'อา._จ._อ._พ._พฤ._ศ._ส.'.split('_'), | ||
weekdaysMin: 'อา._จ._อ._พ._พฤ._ศ._ส.'.split('_'), | ||
weekdaysParseExact: true, | ||
longDateFormat: { | ||
LT: 'H:mm', | ||
LTS: 'H:mm:ss', | ||
L: 'DD/MM/YYYY', | ||
LL: 'D MMMM YYYY', | ||
LLL: 'D MMMM YYYY เวลา H:mm', | ||
LLLL: 'วันddddที่ D MMMM YYYY เวลา H:mm' | ||
}, | ||
meridiemParse: /ก่อนเที่ยง|หลังเที่ยง/, | ||
isPM(input) { | ||
return input === 'หลังเที่ยง'; | ||
}, | ||
meridiem(hour, minute, isLower) { | ||
if (hour < 12) { | ||
return 'ก่อนเที่ยง'; | ||
} else { | ||
return 'หลังเที่ยง'; | ||
} | ||
}, | ||
calendar: { | ||
sameDay: '[วันนี้ เวลา] LT', | ||
nextDay: '[พรุ่งนี้ เวลา] LT', | ||
nextWeek: 'dddd[หน้า เวลา] LT', | ||
lastDay: '[เมื่อวานนี้ เวลา] LT', | ||
lastWeek: '[วัน]dddd[ที่แล้ว เวลา] LT', | ||
sameElse: 'L' | ||
}, | ||
relativeTime: { | ||
future: 'อีก %s', | ||
past: '%sที่แล้ว', | ||
s: 'ไม่กี่วินาที', | ||
ss: '%d วินาที', | ||
m: '1 นาที', | ||
mm: '%d นาที', | ||
h: '1 ชั่วโมง', | ||
hh: '%d ชั่วโมง', | ||
d: '1 วัน', | ||
dd: '%d วัน', | ||
M: '1 เดือน', | ||
MM: '%d เดือน', | ||
y: '1 ปี', | ||
yy: '%d ปี' | ||
}, | ||
preinput(input: Date): Date { | ||
// just year-543 of input before next step | ||
let preinputDate = new Date(input); | ||
preinputDate.setFullYear(input.getFullYear()-543); | ||
return preinputDate; | ||
}, | ||
postvalue(value: Date): Date { | ||
// just year+543 of value before display on ui | ||
let preinputDate = new Date(value); | ||
preinputDate.setFullYear(value.getFullYear()+543); | ||
return preinputDate; | ||
} | ||
}; |
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,16 @@ | ||
// tslint:disable:max-line-length max-file-line-count prefer-const forin prefer-template one-variable-per-declaration newline-before-return | ||
// tslint:disable:binary-expression-operand-order comment-format one-line no-var-keyword object-literal-shorthand | ||
// tslint:disable:variable-name no-shadowed-variable | ||
|
||
import { assertEq } from '../test-helpers'; | ||
import { thBeLocale } from '../../i18n/th-be'; | ||
|
||
describe('locale: th-be', () => { | ||
it('prevalue should -543 of years', function () { | ||
assertEq(thBeLocale.preinput(new Date(2553, 1, 14)).getTime(), new Date(2010, 1, 14).getTime()); | ||
}); | ||
|
||
it('postvalue should +543 of years', function () { | ||
assertEq(thBeLocale.postvalue(new Date(2010, 1, 14)).getTime(), new Date(2553, 1, 14).getTime()); | ||
}); | ||
}); |
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 |
---|---|---|
|
@@ -36,6 +36,7 @@ export { | |
slLocale, | ||
svLocale, | ||
thLocale, | ||
thBeLocale, | ||
trLocale, | ||
ukLocale, | ||
viLocale, | ||
|
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