format(date: NgbDateStruct): string {
     if (date === null) {
         return '';
     }
     const d = new Date(date.year, date.month - 1, date.day);
     return isValid(d) ? format(d, this.dateFormat) : '';
 }
Ejemplo n.º 2
0
	// Performs pre-processing before stringifying from JSON
	private stringify(schedule: ScheduledTransaction): ScheduledTransaction {
		// To avoid timezone issue, convert the native JS date back to a string ("YYYY-MM-DD") before saving
		const scheduleCopy = angular.copy(schedule);

		scheduleCopy.next_due_date = format(scheduleCopy.next_due_date, "YYYY-MM-DD");

		return scheduleCopy;
	}
 parse(value: string): NgbDateStruct {
     if (!value) {
         return null;
     }
     const d = new Date(format(value, this.dateFormat));
     return isValid(d) ? { year: d.getFullYear(),
                            month: d.getMonth() + 1,
                            day: d.getDate() } : null;
 }
Ejemplo n.º 4
0
		it("should convert the next due date from a date to a string", (): void => {
			schedule.next_due_date.should.be.a("string");
			schedule.next_due_date.should.deep.equal(format(new Date(), "YYYY-MM-DD"));
		});
Ejemplo n.º 5
0
		beforeEach((): ScheduledTransaction => (schedule = scheduleModel["parse"](createScheduledBasicTransaction({next_due_date: format(new Date(), "YYYY-MM-DD HH:mm:ss")}))));
Ejemplo n.º 6
0
		it("should convert the transaction date from a date to a string", (): void => {
			(transaction.transaction_date as string).should.be.a("string");
			(transaction.transaction_date as string).should.deep.equal(format(new Date(), "YYYY-MM-DD"));
		});
Ejemplo n.º 7
0
		beforeEach((): Transaction => (transaction = transactionModel["parse"](createBasicTransaction({transaction_date: format(new Date(), "YYYY-MM-DD HH:mm:ss")}))));