mirror of
https://github.com/scottlamb/moonfire-nvr.git
synced 2025-11-26 04:26:12 -05:00
A little more UI refactor, cleanup, eslint more strict (#54)
* A little more UI refactor, cleanup, eslint more strict * Split out imports for jQuery components and put them where needed. * No longer do all of it in application module. * Prepares better for code splitting. * Split out video player dialog * Simplifies jquery-ui dependencies for code splitting * Simplifies code * Configure to generate more, but smaller bundles. * Setup some more strict eslint settings * Fix css to import rather than require * Change settings to correctly support tree shaking in production build Signed-off-by: Dolf Starreveld <dolf@starreveld.com> * Remove “old” code from TimeFormatter * Accidentally left behind due to overlapping PRs Signed-off-by: Dolf Starreveld <dolf@starreveld.com>
This commit is contained in:
committed by
Scott Lamb
parent
eaae640703
commit
f5aa0080bb
@@ -32,7 +32,7 @@
|
||||
|
||||
import moment from 'moment-timezone';
|
||||
|
||||
export const internalTimeFormat = 'YYYY-MM-DDTHH:mm:ss:FFFFFZ';
|
||||
|
||||
export const defaultTimeFormat = 'YYYY-MM-DD HH:mm:ss';
|
||||
|
||||
/**
|
||||
@@ -117,50 +117,3 @@ export default class TimeFormatter {
|
||||
return moment.tz(ms, this._tz).format(format);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Specialized class similar to TimeFormatter but forcing a specific time format
|
||||
* for internal usage purposes.
|
||||
*/
|
||||
export class TimeStamp90kFormatter {
|
||||
/**
|
||||
* Construct from just a timezone specification.
|
||||
*
|
||||
* @param {String} tz Timezone
|
||||
*/
|
||||
constructor(tz) {
|
||||
this._formatter = new TimeFormatter(internalTimeFormat, tz);
|
||||
}
|
||||
|
||||
/**
|
||||
* Format a timestamp in 90k units using internal format.
|
||||
*
|
||||
* @param {Number} ts90k timestamp in 90,000ths of a second resolution
|
||||
* @return {String} Formatted timestamp
|
||||
*/
|
||||
formatTimeStamp90k(ts90k) {
|
||||
return this._formatter.formatTimeStamp90k(ts90k);
|
||||
}
|
||||
|
||||
/**
|
||||
* Given two timestamp return formatted versions of both, where the second
|
||||
* one may have been shortened if it falls on the same date as the first one.
|
||||
*
|
||||
* @param {Number} ts1 First timestamp in 90k units
|
||||
* @param {Number} ts2 Secodn timestamp in 90k units
|
||||
* @return {Array} Array with two elements: [ ts1Formatted, ts2Formatted ]
|
||||
*/
|
||||
formatSameDayShortened(ts1, ts2) {
|
||||
let ts1Formatted = this.formatTimeStamp90k(ts1);
|
||||
let ts2Formatted = this.formatTimeStamp90k(ts2);
|
||||
let timePos = this._formatter.formatStr.indexOf('T');
|
||||
if (timePos != -1) {
|
||||
const datePortion = ts1Formatted.substr(0, timePos);
|
||||
ts1Formatted = datePortion + ' ' + ts1Formatted.substr(timePos + 1);
|
||||
if (ts2Formatted.startsWith(datePortion)) {
|
||||
ts2Formatted = ts2Formatted.substr(timePos + 1);
|
||||
}
|
||||
}
|
||||
return [ts1Formatted, ts2Formatted];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user