Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | 7x 7x 7x 3x 2x 23x 19x 19x 4x | import { DimensionSubtype } from '../enums'; import Dimension from './dimension'; import { DateTimeFormatter, getMinDiff } from '../utils'; /** * Represents datetime field subtype. * * @extends Dimension */ class DateTime extends Dimension { /** * Creates new DateTime field instance. * * @param {string} name - The name of the field. * @param {Array} data - An array containing the field data. * @param {Object} schema - The schema for the field. */ constructor(name, data, schema) { super(name, data, schema); this.subtype = DimensionSubtype.TEMPORAL; this.minDiff = getMinDiff(this.data); } /** * Getter for subType value of the field. * * @return {string} Returns subType of the field. */ subType() { return this.subtype; } getMinDiff () { return this.minDiff; } /** * A hook which is called for every entry(cell) of the column. * * @param {*} val - The current entry present in the column while iteration. * @return {number} Returns the total timestamps in millisecond. */ parse(val) { if (this.schema.format) { this._dtf = this._dtf || new DateTimeFormatter(this.schema.format); return this._dtf.getNativeDate(val).getTime(); } // If format is not present then it means the value is such that the it could be directly passed to date // constructor return +new Date(val); } } export default DateTime; |