state.take(1).subscribe((s) => {
   expect(moment(u).isSame(s.items.lastUpdate)).toBeTruthy();
 });
 ctx.options.grid.markings.forEach((m, i) => {
   console.log(
     `Marking (${i}): from=${moment(m.xaxis.from).format()}, to=${moment(m.xaxis.to).format()}, color=${m.color}`
   );
 });
 it('should work', () => {
   expect(startViewDate(viewCells))
     .toEqual(moment('2018-06-10').toDate());
 });
      it('should add one fill between sunday 23:00 and monday 01:40', () => {
        const markings = ctx.options.grid.markings;

        expect(moment(markings[0].xaxis.from).format()).toBe(moment('2018-12-10T00:00:00+01:00').format());
        expect(moment(markings[0].xaxis.to).format()).toBe(moment('2018-12-10T02:40:00+01:00').format());
      });
      it('should add one fill at each sunday between 20:00 and 23:00', () => {
        const markings = ctx.options.grid.markings;

        expect(moment(markings[0].xaxis.from).format()).toBe(moment('2018-03-18T21:00:00+01:00').format());
        expect(moment(markings[0].xaxis.to).format()).toBe(moment('2018-03-19T00:00:00+01:00').format());

        expect(moment(markings[1].xaxis.from).format()).toBe(moment('2018-03-25T22:00:00+02:00').format());
        expect(moment(markings[1].xaxis.to).format()).toBe(moment('2018-03-26T01:00:00+02:00').format());

        expect(moment(markings[2].xaxis.from).format()).toBe(moment('2018-04-01T22:00:00+02:00').format());
        expect(moment(markings[2].xaxis.to).format()).toBe(moment('2018-04-02T01:00:00+02:00').format());
      });
 beforeEach(() => {
   builder.rawQueryString = 'query=Tablename | where myTime >= $__from and myTime <= $__to';
   builder.options.range.to = moment().subtract(1, 'hour');
   builder.options.rangeRaw.to = 'now-1h';
 });
      it('should add one fill between 00:00 and 05:00 each day', () => {
        const markings = ctx.options.grid.markings;

        expect(moment(markings[0].xaxis.from).format()).toBe(moment('2018-12-01T01:00:00+01:00').format());
        expect(moment(markings[0].xaxis.to).format()).toBe(moment('2018-12-01T06:00:00+01:00').format());
        expect(markings[0].color).toBe(colorModes.red.color.fill);

        expect(moment(markings[1].xaxis.from).format()).toBe(moment('2018-12-02T01:00:00+01:00').format());
        expect(moment(markings[1].xaxis.to).format()).toBe(moment('2018-12-02T06:00:00+01:00').format());
        expect(markings[1].color).toBe(colorModes.red.color.fill);

        expect(moment(markings[2].xaxis.from).format()).toBe(moment('2018-12-03T01:00:00+01:00').format());
        expect(moment(markings[2].xaxis.to).format()).toBe(moment('2018-12-03T06:00:00+01:00').format());
        expect(markings[2].color).toBe(colorModes.red.color.fill);
      });
示例#8
0
 ctx.timeSrvMock.timeRange = () => {
   return {
     from: moment(1531468681),
     to: moment(1531489712),
   };
 };
示例#9
0
const time = ({ hours = 0, seconds = 0, minutes = 0 }) => moment(hours * HOUR + minutes * MINUTE + seconds * SECOND);
示例#10
0
import JsonEsc from 'jsonesc';
import moment from 'moment';

const startTime = moment();
const Moment = startTime.constructor;

function encodeMoment(val: any): string {
  return `\u001bTime:${val.toISOString(true)}`;
}

function decodeMoment(str: string): any {
  return moment.parseZone(str.substr(6));
}

let encoder = new JsonEsc();
encoder.registerRaw('Time', Moment, encodeMoment, decodeMoment);

export function encode(value: any): string {
  return encoder.stringifySorted(value, 1);
}

export function decode(str: string): any {
  return encoder.parse(str);
}