Example #1
0
function dayShort(offset) {
  return moment().locale('fi').add(offset, 'days').format('dddd')
    .toLowerCase()
    .slice(0, 2);
}
 transform(value: any, args: Array<any>): string {
   return moment(value).fromNow();
 }
 private converterStringsParaDatas(dados: Array<any>) {
   for (const dado of dados) {
     dado.dia = moment(dado.dia, 'YYYY-MM-DD').toDate();
   }
 }
Example #4
0
export const isHoliday = (date: Moment|Date): boolean => HOLIDAYS.some((holiday: Moment) => holiday.isSame(moment(date), 'day'))
Example #5
0
 .map((holiday: string) => moment(holiday, Config.holidaysFormat))
 constructor(private bucket: string, now = moment()) {
   this.expires = now.add(90, 'days').format(HTTP_DATE_FORMAT) + ' GTM';
   this.exec = promisify(cp.exec);
 }
Example #7
0
 generateFileName(migrationName: string): string {
     return `m${moment().format('YMMDD_HHmmss')}_${migrationName}`;
 }
	it('should return true if the first moment is before the second', (): void => {
		expect(moment('2015-01-01')).to.be.beforeMoment(moment('2016-01-01'));
		expect(moment('2015-01-01')).to.not.be.beforeMoment(moment('2014-01-01'));
	});
	it('should handle timezones', (): void => {
		let est_moment: moment.Moment = moment('2016-01-02T12:00:00.000-05:00').tz('US/Eastern');
		let pst_moment: moment.Moment = moment('2016-01-02T09:00:00.000-08:00').tz('US/Pacific');
		expect(est_moment).to.equalMoment(pst_moment);
	});
 static daysBetween(beginDate, endDate) {
     return moment(endDate)
         .endOf('day')
         .diff(moment(beginDate).startOf('day'), 'days');
 }
 public isVisible(date: string) {
   return moment(date).isAfter(moment());
 }
 static startOfDay(d) {
     return moment(d)
         .startOf('day')
         .toDate();
 }
 static dateToAfterMidnight(d) {
     return moment(d)
         .startOf('day')
         .add(1, 'days')
         .toDate();
 }
Example #14
0
function currentTime() {
  return moment().format('HH:mm');
}
 static currentDate (): moment.Moment {
   return moment().hours(0).minutes(0).seconds(0).milliseconds(0)
 }
	it('should return true if moments are equal', (): void => {
		expect(moment('2015-01-01')).to.be.sameMoment(moment('2015-01-01'));
		expect(moment('2015-01-01')).to.equalMoment(moment('2015-01-01'));
		expect(moment('2015-01-01')).to.not.be.sameMoment(moment('2016-01-01'));
		expect(moment('2015-01-01')).to.not.equalMoment(moment('2016-01-01'));
	});
 constructor(private dpConfig: NgbDatepickerConfig) {
   this.dpConfig.minDate = { year: moment().year() - 100, month: 1, day: 1 };
 }
Example #18
0
 transform(value: Date|moment.Moment, ...args: any[]): any {
     let [format] = args;
     return moment(value).format(format);
 }
Example #19
0
    it('dateTimeToString should respect the option to includeTime if set to false', () => {
      const now = moment(new Date()).toDate();

      const result = DateUtils.dateTimeToString(now, { includeTimeIfToday: false, includeTimeIfThisWeek: false });
      expect(containsTime(result)).toBe(false);
    });
Example #20
0
let me: User      = new User('Juliet', require('images/avatars/female-avatar-1.png'));
let ladycap: User = new User('Lady Capulet', require('images/avatars/female-avatar-2.png'));
let echo: User    = new User('Echo Bot', require('images/avatars/male-avatar-1.png'));
let rev: User     = new User('Reverse Bot', require('images/avatars/female-avatar-4.png'));
let wait: User    = new User('Waiting Bot', require('images/avatars/male-avatar-2.png'));

let tLadycap: Thread = new Thread('tLadycap', ladycap.name, ladycap.avatarSrc);
let tEcho: Thread    = new Thread('tEcho', echo.name, echo.avatarSrc);
let tRev: Thread     = new Thread('tRev', rev.name, rev.avatarSrc);
let tWait: Thread    = new Thread('tWait', wait.name, wait.avatarSrc);


let initialMessages: Array<Message> = [
  new Message({
    author: me,
    sentAt: moment().subtract(45, 'minutes').toDate(),
    text: 'Yet let me weep for such a feeling loss.',
    thread: tLadycap
  }),
  new Message({
    author: ladycap,
    sentAt: moment().subtract(20, 'minutes').toDate(),
    text: 'So shall you feel the loss, but not the friend which you weep for.',
    thread: tLadycap
  }),
  new Message({
    author: echo,
    sentAt: moment().subtract(1, 'minutes').toDate(),
    text: `I\'ll echo whatever you send me`,
    thread: tEcho
  }),
Example #21
0
export const isToday = (date: Moment|Date) => moment().isSame(moment(date), 'day')
Example #22
0
 transform(dateString: String): String {
   return moment(dateString).format("MMMM Do YYYY, h:mm:ss a");
 }
Example #23
0
export const isWeekend = (date: Moment|Date): boolean => {
  const weekday = moment(date).isoWeekday()

  return weekday === SATURDAY || weekday === SUNDAY
}
 static maxDate (): moment.Moment {
   return moment(new Date(9999, 11, 31))
 }
Example #25
0
export function friendlyTime(t) {
    return moment(t).fromNow();
}
 static parse (value: string): moment.Moment {
   if (!value) {
     throw new Error('Value must be defined')
   }
   return moment(value)
 }
import * as moment from 'moment';

var range: moment.Range = moment.range(new Date(2012, 0, 15), new Date(2012, 4, 23));
var range2: moment.Range = moment.range(moment("2011-04-15", "YYYY-MM-DD"), moment("2011-11-27", "YYYY-MM-DD"));
var range3: moment.Range = moment.range([moment("2011-04-15", "YYYY-MM-DD"), moment("2011-11-27", "YYYY-MM-DD")]);
var range4: moment.Range = moment.range("2015-01-17T09:50:04+00:00/2015-04-17T08:29:55+00:00");

var date: moment.Moment = moment('2012-05- 15');

var res1: boolean = range.contains(date);
var res2: boolean = range.contains(date, false);
var res3: boolean = range.contains(date, true);

var res4: boolean = date.within(range);

var res5: boolean = range.overlaps(range2);

var res6: moment.Range = range.intersect(range2);

var res7: moment.Range = range.add(range2);

var res8: Array<moment.Range> = range.subtract(range2);

range.by('days', (moment: moment.Moment) => {  });
range.by(range2, (moment: moment.Moment) => {  });
range.by('d', (moment: moment.Moment) => {  }, true);

var res9: boolean = range.isSame(range2);

var res10: number = range.diff('months');
var res11: number = range.diff('days');
 static currentDateTime (): moment.Moment {
   return moment()
 }
Example #29
0
 public fromLink(dateString: string): Moment {
   const date = moment(dateString, 'YYYY-MM-DD');
   return date.isValid() ? date : null;
 }
Example #30
0
import { YesNoOption } from 'models/yesNoOption'
import { Evidence } from 'forms/models/evidence'
import { EvidenceType } from 'forms/models/evidenceType'
import { Eligibility } from 'eligibility/model/eligibility'
import { ClaimType } from 'eligibility/model/claimType'
import { DefendantAgeOption } from 'eligibility/model/defendantAgeOption'
import { AlreadyPaid } from 'response/form/models/alreadyPaid'
import { HowMuchHaveYouPaid } from 'response/form/models/howMuchHaveYouPaid'
import { MomentFactory } from 'shared/momentFactory'
import * as moment from 'moment'
import { CompanyDetails } from 'forms/models/companyDetails'

const serviceBaseURL: string = `${config.get('draft-store.url')}`

export const samplePaidInFullDraftObj = {
  datePaid: moment()
}

export const sampleOrganisationDetails = {
  type: 'organisation',
  name: 'John Smith',
  address: { line1: 'Apartment 99', line2: '', line3: '', city: 'London', postcode: 'SE28 0JE' } as Address,
  hasCorrespondenceAddress: false,
  contactPerson: 'Mary Richards'
}

const commonClaimObject = {
  externalId: 'fe6e9413-e804-48d5-bbfd-645917fc46e5',
  eligibility: {
    claimValue: ClaimValue.UNDER_10000,
    helpWithFees: YesNoOption.NO,