fix: hour display luxon
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import { Component, Input } from '@angular/core';
|
import { Component, Input } from '@angular/core';
|
||||||
import moment from 'moment';
|
import { DateTime } from "luxon";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-hour-display',
|
selector: 'app-hour-display',
|
||||||
@@ -12,10 +12,10 @@ export class HourDisplayComponent {
|
|||||||
|
|
||||||
style () {
|
style () {
|
||||||
if (/(0+[0-9]|1[0-9]|2[0-3]):(0+[0-9]|[1-5][0-9])/g.test(this.value)) {
|
if (/(0+[0-9]|1[0-9]|2[0-3]):(0+[0-9]|[1-5][0-9])/g.test(this.value)) {
|
||||||
var diff = moment(this.value, 'HH:mm').diff(moment(), 'minutes');
|
var diff = DateTime.fromFormat(this.value, "HH:mm").diffNow("minutes")
|
||||||
if (diff > 30) {
|
if (diff.as("minutes") > 30) {
|
||||||
return { "background-color": "red" }
|
return { "background-color": "red" }
|
||||||
} else if (diff > 0) {
|
} else if (diff.as("minutes") > 0) {
|
||||||
return { "background-color": "yellow", "color": "black"}
|
return { "background-color": "yellow", "color": "black"}
|
||||||
} else {
|
} else {
|
||||||
return { "background-color": "green"}
|
return { "background-color": "green"}
|
||||||
|
|||||||
Reference in New Issue
Block a user