我们如何将12小时角色的矢量转换为24小时?例如,假设我有一个向量
v = c('9AM','10AM','1PM','5PM')
我正在尝试根据AM / PM获得9,10,13,17的输出并附加AM / PM。
答案 0 :(得分:6)
>>> times$hour #as commented by @thelatemail
[1] 9 10 13 17
如果你只需要一小时
>>> library(lubridate)
>>> hour(times)
[1] 9 10 13 17
或
describe('HomePage', () => {
let fixture: ComponentFixture<HomePage>;
let comp: HomePage;
let de: DebugElement;
let title: DebugElement;
let el: HTMLElement;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [HomePage],
imports: [
IonicModule.forRoot(HomePage)
],
providers: [
NavController
]
}).compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(HomePage);
comp = fixture.componentInstance;
de = fixture.debugElement.query(By.css('h4'));
title = fixture.debugElement.query(By.css('.toolbar-title'));
el = de.nativeElement;
});
it('initializes', () => {
expect(fixture).toBeTruthy();
expect(comp).toBeDefined();
});
it('checks for the h4 element in the DOM', () => {
fixture.detectChanges();
expect(el.textContent).toContain('Testing');
});
it('checks the ion-title', ()=>{
fixture.detectChanges();
const _title = title.nativeElement;
expect(_title.innerText).toMatch(/ionic/i,
'<div class="toolbar-title"> should say something about "Ionic"');
});
});