mirror of https://github.com/keeweb/keeweb
fix
parent
22754f32ec
commit
f4f2ddfb3c
|
@ -2,7 +2,7 @@
|
|||
import kdbxweb from 'kdbxweb';
|
||||
import { RuntimeInfo } from 'const/runtime-info';
|
||||
import { Links } from 'const/links';
|
||||
import { DateFormat } from 'comp/util/date-format';
|
||||
import { DateFormat } from 'comp/i18n/date-format';
|
||||
import { StringFormat } from 'util/formatting/string-format';
|
||||
import { Locale } from 'util/locale';
|
||||
|
||||
|
|
|
@ -2,25 +2,25 @@ import { SettingsManager } from 'comp/settings/settings-manager';
|
|||
import { StringFormat } from 'util/formatting/string-format';
|
||||
|
||||
const DateFormat = {
|
||||
getMonthsForLocale() {
|
||||
months() {
|
||||
const format = new Intl.DateTimeFormat(SettingsManager.activeLocale, { month: 'long' });
|
||||
const months = [];
|
||||
for (let month = 0; month < 12; month++) {
|
||||
months.push(format.format(new Date(Date.UTC(2008, month))));
|
||||
months.push(format.format(new Date(2008, month)));
|
||||
}
|
||||
return months;
|
||||
},
|
||||
|
||||
getWeekDaysForLocale() {
|
||||
weekDays() {
|
||||
const format = new Intl.DateTimeFormat(SettingsManager.activeLocale, { weekday: 'long' });
|
||||
const weekdays = [];
|
||||
for (let day = 1; day < 8; day++) {
|
||||
weekdays.push(format.format(new Date(Date.UTC(2007, 9, 6 + day))));
|
||||
weekdays.push(format.format(new Date(2007, 9, 6 + day)));
|
||||
}
|
||||
return weekdays;
|
||||
},
|
||||
|
||||
getWeekdaysShortForLocale() {
|
||||
shortWeekDays() {
|
||||
const format = new Intl.DateTimeFormat(SettingsManager.activeLocale, { weekday: 'short' });
|
||||
const weekdays = [];
|
||||
for (let day = 1; day < 8; day++) {
|
||||
|
@ -35,12 +35,8 @@ const DateFormat = {
|
|||
}
|
||||
return dt
|
||||
? new Intl.DateTimeFormat(SettingsManager.activeLocale, {
|
||||
year: 'numeric',
|
||||
month: 'short',
|
||||
day: 'numeric',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
second: '2-digit'
|
||||
dateStyle: 'medium',
|
||||
timeStyle: 'medium'
|
||||
}).format(dt)
|
||||
: '';
|
||||
},
|
|
@ -16,7 +16,7 @@ import { YubiKeyOtpModel } from 'models/external/yubikey-otp-model';
|
|||
import { MenuModel } from 'models/menu/menu-model';
|
||||
import { PluginManager } from 'plugins/plugin-manager';
|
||||
import { Features } from 'util/features';
|
||||
import { DateFormat } from 'comp/util/date-format';
|
||||
import { DateFormat } from 'comp/i18n/date-format';
|
||||
import { UrlFormat } from 'util/formatting/url-format';
|
||||
import { IdGenerator } from 'util/generators/id-generator';
|
||||
import { Locale } from 'util/locale';
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { DateFormat } from 'comp/util/date-format';
|
||||
import { DateFormat } from 'comp/i18n/date-format';
|
||||
import { Locale } from 'util/locale';
|
||||
|
||||
const EntryPresenter = function (descField, noColor, activeEntryId) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { Locale } from 'util/locale';
|
||||
import { StringFormat } from 'util/formatting/string-format';
|
||||
import { DateFormat } from 'comp/util/date-format';
|
||||
import { DateFormat } from 'comp/i18n/date-format';
|
||||
import { AppModel } from 'models/app-model';
|
||||
import { FieldViewReadOnly } from 'views/fields/field-view-read-only';
|
||||
import { FieldViewOtp } from 'views/fields/field-view-otp';
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { View } from 'framework/views/view';
|
||||
import { Alerts } from 'comp/ui/alerts';
|
||||
import { Keys } from 'const/keys';
|
||||
import { DateFormat } from 'comp/util/date-format';
|
||||
import { DateFormat } from 'comp/i18n/date-format';
|
||||
import { StringFormat } from 'util/formatting/string-format';
|
||||
import { Locale } from 'util/locale';
|
||||
import { Copyable } from 'framework/views/copyable';
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import Pikaday from 'pikaday';
|
||||
import { DateFormat } from 'comp/util/date-format';
|
||||
import { DateFormat } from 'comp/i18n/date-format';
|
||||
import { FieldViewText } from 'views/fields/field-view-text';
|
||||
|
||||
class FieldViewDate extends FieldViewText {
|
||||
|
@ -29,9 +29,9 @@ class FieldViewDate extends FieldViewText {
|
|||
i18n: {
|
||||
previousMonth: '',
|
||||
nextMonth: '',
|
||||
months: DateFormat.getMonthsForLocale(),
|
||||
weekdays: DateFormat.getWeekDaysForLocale(),
|
||||
weekdaysShort: DateFormat.getWeekdaysShortForLocale()
|
||||
months: DateFormat.months(),
|
||||
weekdays: DateFormat.weekDays(),
|
||||
weekdaysShort: DateFormat.shortWeekDays()
|
||||
}
|
||||
});
|
||||
this.picker.adjustPosition = this.adjustPickerPosition.bind(this);
|
||||
|
|
|
@ -8,7 +8,7 @@ import { YubiKey } from 'comp/app/yubikey';
|
|||
import { UsbListener } from 'comp/app/usb-listener';
|
||||
import { Links } from 'const/links';
|
||||
import { AppSettingsModel } from 'models/app-settings-model';
|
||||
import { DateFormat } from 'comp/util/date-format';
|
||||
import { DateFormat } from 'comp/i18n/date-format';
|
||||
import { UrlFormat } from 'util/formatting/url-format';
|
||||
import { PasswordPresenter } from 'util/formatting/password-presenter';
|
||||
import { Locale } from 'util/locale';
|
||||
|
|
|
@ -12,7 +12,7 @@ import { AppSettingsModel } from 'models/app-settings-model';
|
|||
import { UpdateModel } from 'models/update-model';
|
||||
import { SemVer } from 'util/data/semver';
|
||||
import { Features } from 'util/features';
|
||||
import { DateFormat } from 'comp/util/date-format';
|
||||
import { DateFormat } from 'comp/i18n/date-format';
|
||||
import { Locale } from 'util/locale';
|
||||
import { SettingsLogsView } from 'views/settings/settings-logs-view';
|
||||
import { SettingsPrvView } from 'views/settings/settings-prv-view';
|
||||
|
|
|
@ -10,7 +10,7 @@ import { PluginManager } from 'plugins/plugin-manager';
|
|||
import { Comparators } from 'util/data/comparators';
|
||||
import { SemVer } from 'util/data/semver';
|
||||
import { Features } from 'util/features';
|
||||
import { DateFormat } from 'comp/util/date-format';
|
||||
import { DateFormat } from 'comp/i18n/date-format';
|
||||
import { Locale } from 'util/locale';
|
||||
import template from 'templates/settings/settings-plugins.hbs';
|
||||
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
import { expect } from 'chai';
|
||||
import { DateFormat } from 'comp/i18n/date-format';
|
||||
|
||||
describe('DateFormat', () => {
|
||||
const dt = new Date(2020, 0, 2, 3, 4, 5, 6);
|
||||
|
||||
it('should return months', () => {
|
||||
expect(DateFormat.months()).to.eql([
|
||||
'January',
|
||||
'February',
|
||||
'March',
|
||||
'April',
|
||||
'May',
|
||||
'June',
|
||||
'July',
|
||||
'August',
|
||||
'September',
|
||||
'October',
|
||||
'November',
|
||||
'December'
|
||||
]);
|
||||
});
|
||||
|
||||
it('should return week days', () => {
|
||||
expect(DateFormat.weekDays()).to.eql([
|
||||
'Sunday',
|
||||
'Monday',
|
||||
'Tuesday',
|
||||
'Wednesday',
|
||||
'Thursday',
|
||||
'Friday',
|
||||
'Saturday'
|
||||
]);
|
||||
});
|
||||
|
||||
it('should return short week days', () => {
|
||||
expect(DateFormat.shortWeekDays()).to.eql([
|
||||
'Sun',
|
||||
'Mon',
|
||||
'Tue',
|
||||
'Wed',
|
||||
'Thu',
|
||||
'Fri',
|
||||
'Sat'
|
||||
]);
|
||||
});
|
||||
|
||||
it('should format date', () => {
|
||||
expect(DateFormat.dStr(dt)).to.eql('Jan 2, 2020');
|
||||
});
|
||||
|
||||
it('should format date and time', () => {
|
||||
expect(DateFormat.dtStr(dt)).to.eql('Jan 2, 2020, 3:04:05 AM');
|
||||
});
|
||||
|
||||
it('should format date and time in sortable format', () => {
|
||||
expect(DateFormat.dtStrFs(dt)).to.eql('2020-01-02T03-04-05');
|
||||
});
|
||||
});
|
|
@ -1,18 +0,0 @@
|
|||
import { expect } from 'chai';
|
||||
import { DateFormat } from 'comp/util/date-format';
|
||||
|
||||
describe('DateFormat', () => {
|
||||
const dt = new Date(2020, 0, 2, 3, 4, 5, 6);
|
||||
|
||||
it('should format date', () => {
|
||||
expect(DateFormat.dStr(dt)).to.eql('Jan 2, 2020');
|
||||
});
|
||||
|
||||
it('should format date and time', () => {
|
||||
expect(DateFormat.dtStr(dt)).to.eql('Jan 2, 2020, 03:04:05');
|
||||
});
|
||||
|
||||
it('should format date and time in sortable format', () => {
|
||||
expect(DateFormat.dtStrFs(dt)).to.eql('2020-01-02T03-04-05');
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue