mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-23 22:17:40 +08:00
@ -7,7 +7,7 @@ import {ionicBootstrap} from '../../../../../src';
|
|||||||
})
|
})
|
||||||
class E2EPage {
|
class E2EPage {
|
||||||
wwwInvented = '1989';
|
wwwInvented = '1989';
|
||||||
time = '13:47';
|
time = '13:47:00';
|
||||||
netscapeReleased = '1994-12-15T13:47:20.789';
|
netscapeReleased = '1994-12-15T13:47:20.789';
|
||||||
operaReleased = '1995-04-15';
|
operaReleased = '1995-04-15';
|
||||||
firefoxReleased = '2002-09-23T15:03:46.789';
|
firefoxReleased = '2002-09-23T15:03:46.789';
|
||||||
|
@ -87,4 +87,9 @@
|
|||||||
{{convertedDate}}
|
{{convertedDate}}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<ion-item>
|
||||||
|
<ion-label>HH:mm:ss</ion-label>
|
||||||
|
<ion-datetime displayFormat="HH:mm:ss" [(ngModel)]="time"></ion-datetime>
|
||||||
|
</ion-item>
|
||||||
|
|
||||||
</ion-content>
|
</ion-content>
|
||||||
|
@ -66,7 +66,7 @@ export function renderTextFormat(format: string, value: any, date: DateTimeData,
|
|||||||
|
|
||||||
if (format === FORMAT_YY || format === FORMAT_MM ||
|
if (format === FORMAT_YY || format === FORMAT_MM ||
|
||||||
format === FORMAT_DD || format === FORMAT_HH ||
|
format === FORMAT_DD || format === FORMAT_HH ||
|
||||||
format === FORMAT_mm) {
|
format === FORMAT_mm || format === FORMAT_ss) {
|
||||||
return twoDigit(value);
|
return twoDigit(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,6 +136,12 @@ export function dateValueRange(format: string, min: DateTimeData, max: DateTimeD
|
|||||||
opts.push(i);
|
opts.push(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else if (format === FORMAT_ss || format === FORMAT_s) {
|
||||||
|
// seconds
|
||||||
|
for (i = 0; i < 60; i++) {
|
||||||
|
opts.push(i);
|
||||||
|
}
|
||||||
|
|
||||||
} else if (format === FORMAT_A || format === FORMAT_a) {
|
} else if (format === FORMAT_A || format === FORMAT_a) {
|
||||||
// AM/PM
|
// AM/PM
|
||||||
opts.push('am', 'pm');
|
opts.push('am', 'pm');
|
||||||
@ -432,6 +438,8 @@ const FORMAT_hh = 'hh';
|
|||||||
const FORMAT_h = 'h';
|
const FORMAT_h = 'h';
|
||||||
const FORMAT_mm = 'mm';
|
const FORMAT_mm = 'mm';
|
||||||
const FORMAT_m = 'm';
|
const FORMAT_m = 'm';
|
||||||
|
const FORMAT_ss = 'ss';
|
||||||
|
const FORMAT_s = 's';
|
||||||
const FORMAT_A = 'A';
|
const FORMAT_A = 'A';
|
||||||
const FORMAT_a = 'a';
|
const FORMAT_a = 'a';
|
||||||
|
|
||||||
@ -447,11 +455,13 @@ const FORMAT_KEYS = [
|
|||||||
{ f: FORMAT_HH, k: 'hour' },
|
{ f: FORMAT_HH, k: 'hour' },
|
||||||
{ f: FORMAT_hh, k: 'hour' },
|
{ f: FORMAT_hh, k: 'hour' },
|
||||||
{ f: FORMAT_mm, k: 'minute' },
|
{ f: FORMAT_mm, k: 'minute' },
|
||||||
|
{ f: FORMAT_ss, k: 'second' },
|
||||||
{ f: FORMAT_M, k: 'month' },
|
{ f: FORMAT_M, k: 'month' },
|
||||||
{ f: FORMAT_D, k: 'day' },
|
{ f: FORMAT_D, k: 'day' },
|
||||||
{ f: FORMAT_H, k: 'hour' },
|
{ f: FORMAT_H, k: 'hour' },
|
||||||
{ f: FORMAT_h, k: 'hour' },
|
{ f: FORMAT_h, k: 'hour' },
|
||||||
{ f: FORMAT_m, k: 'minute' },
|
{ f: FORMAT_m, k: 'minute' },
|
||||||
|
{ f: FORMAT_s, k: 'second' },
|
||||||
{ f: FORMAT_A, k: 'ampm' },
|
{ f: FORMAT_A, k: 'ampm' },
|
||||||
{ f: FORMAT_a, k: 'ampm' },
|
{ f: FORMAT_a, k: 'ampm' },
|
||||||
];
|
];
|
||||||
|
@ -114,7 +114,7 @@ describe('convertDataToISO', () => {
|
|||||||
expect(str).toEqual('13:47:20.789');
|
expect(str).toEqual('13:47:20.789');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should convert DateTimeData to HH:mm:SS string', () => {
|
it('should convert DateTimeData to HH:mm:ss string', () => {
|
||||||
var data: datetime.DateTimeData = {
|
var data: datetime.DateTimeData = {
|
||||||
year: null,
|
year: null,
|
||||||
month: null,
|
month: null,
|
||||||
@ -201,6 +201,11 @@ describe('convertFormatToKey', () => {
|
|||||||
expect(datetime.convertFormatToKey('m')).toEqual('minute');
|
expect(datetime.convertFormatToKey('m')).toEqual('minute');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should convert second formats to their DateParse key', () => {
|
||||||
|
expect(datetime.convertFormatToKey('ss')).toEqual('second');
|
||||||
|
expect(datetime.convertFormatToKey('s')).toEqual('second');
|
||||||
|
});
|
||||||
|
|
||||||
it('should convert am/pm formats to their DateParse key', () => {
|
it('should convert am/pm formats to their DateParse key', () => {
|
||||||
expect(datetime.convertFormatToKey('A')).toEqual('ampm');
|
expect(datetime.convertFormatToKey('A')).toEqual('ampm');
|
||||||
expect(datetime.convertFormatToKey('a')).toEqual('ampm');
|
expect(datetime.convertFormatToKey('a')).toEqual('ampm');
|
||||||
@ -317,24 +322,26 @@ describe('parseTemplate', () => {
|
|||||||
expect(formats[1]).toEqual('mm');
|
expect(formats[1]).toEqual('mm');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should get formats from template "m mm h hh H HH D DD DDD DDDD M MM MMM MMMM YY YYYY"', () => {
|
it('should get formats from template "s ss m mm h hh H HH D DD DDD DDDD M MM MMM MMMM YY YYYY"', () => {
|
||||||
var formats = datetime.parseTemplate('m mm h hh H HH D DD DDD DDDD M MM MMM MMMM YY YYYY');
|
var formats = datetime.parseTemplate('s ss m mm h hh H HH D DD DDD DDDD M MM MMM MMMM YY YYYY');
|
||||||
expect(formats[0]).toEqual('m');
|
expect(formats[0]).toEqual('s');
|
||||||
expect(formats[1]).toEqual('mm');
|
expect(formats[1]).toEqual('ss');
|
||||||
expect(formats[2]).toEqual('h');
|
expect(formats[2]).toEqual('m');
|
||||||
expect(formats[3]).toEqual('hh');
|
expect(formats[3]).toEqual('mm');
|
||||||
expect(formats[4]).toEqual('H');
|
expect(formats[4]).toEqual('h');
|
||||||
expect(formats[5]).toEqual('HH');
|
expect(formats[5]).toEqual('hh');
|
||||||
expect(formats[6]).toEqual('D');
|
expect(formats[6]).toEqual('H');
|
||||||
expect(formats[7]).toEqual('DD');
|
expect(formats[7]).toEqual('HH');
|
||||||
expect(formats[8]).toEqual('DDD');
|
expect(formats[8]).toEqual('D');
|
||||||
expect(formats[9]).toEqual('DDDD');
|
expect(formats[9]).toEqual('DD');
|
||||||
expect(formats[10]).toEqual('M');
|
expect(formats[10]).toEqual('DDD');
|
||||||
expect(formats[11]).toEqual('MM');
|
expect(formats[11]).toEqual('DDDD');
|
||||||
expect(formats[12]).toEqual('MMM');
|
expect(formats[12]).toEqual('M');
|
||||||
expect(formats[13]).toEqual('MMMM');
|
expect(formats[13]).toEqual('MM');
|
||||||
expect(formats[14]).toEqual('YY');
|
expect(formats[14]).toEqual('MMM');
|
||||||
expect(formats[15]).toEqual('YYYY');
|
expect(formats[15]).toEqual('MMMM');
|
||||||
|
expect(formats[16]).toEqual('YY');
|
||||||
|
expect(formats[17]).toEqual('YYYY');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should get formats from template YYMMMMDDHHmm', () => {
|
it('should get formats from template YYMMMMDDHHmm', () => {
|
||||||
|
Reference in New Issue
Block a user