Skip to content

Commit

Permalink
fixes i forgot to push before merging #2904 (#2978)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmalerba committed Apr 20, 2017
1 parent 8976e33 commit d9c7f0b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
16 changes: 8 additions & 8 deletions src/lib/core/datetime/simple-date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ export class SimpleDate {
* Create a SimpleDate from a native JS Date object.
* @param nativeDate The native JS Date object to convert.
*/
static fromNativeDate(nativeDate: Date) {
static fromNativeDate(nativeDate: Date): SimpleDate {
return new SimpleDate(nativeDate.getFullYear(), nativeDate.getMonth(), nativeDate.getDate());
}

/** Creates a SimpleDate object representing today. */
static today() {
static today(): SimpleDate {
return SimpleDate.fromNativeDate(new Date());
}

Expand All @@ -29,38 +29,38 @@ export class SimpleDate {
}

/** The year component of this date. */
get year() {
get year(): number {
return this._date.getFullYear();
}

/** The month component of this date. (0-indexed, 0 = January). */
get month() {
get month(): number {
return this._date.getMonth();
}

/** The date component of this date. (1-indexed, 1 = 1st of month). */
get date() {
get date(): number {
return this._date.getDate();
}

/** The day component of this date. (0-indexed, 0 = Sunday) */
get day() {
get day(): number {
return this._date.getDay();
}

/**
* Adds an amount of time (in days, months, and years) to the date.
* @param amount The amount of time to add.
*/
add(amount: {days: number, months: number, years: number}) {
add(amount: {days: number, months: number, years: number}): SimpleDate {
return new SimpleDate(
this.year + amount.years || 0,
this.month + amount.months || 0,
this.date + amount.days || 0);
}

/** Converts the SimpleDate to a native JS Date object. */
toNativeDate() {
toNativeDate(): Date {
return new Date(this.year, this.month, this.date);
}
}
5 changes: 3 additions & 2 deletions src/lib/datepicker/calendar-table.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ $mat-calendar-table-font-size: 12px !default;
$mat-calendar-table-cell-padding: 1px !default;
$mat-calendar-table-cell-content-size: 32px !default;
$mat-calendar-table-cell-content-border-width: 1px !default;
$mat-calendar-table-label-padding-start: 10px !default;


.mat-calendar-table-table {
Expand All @@ -11,7 +12,7 @@ $mat-calendar-table-cell-content-border-width: 1px !default;

.mat-calendar-table-label {
height: $mat-calendar-table-cell-content-size;
padding: 0 0 0 10px;
padding: 0 0 0 $mat-calendar-table-label-padding-start;
text-align: left;
font-weight: normal;
}
Expand All @@ -33,7 +34,7 @@ $mat-calendar-table-cell-content-border-width: 1px !default;

[dir='rtl'] {
.mat-calendar-table-label {
padding: 0 10px 0 0;
padding: 0 $mat-calendar-table-label-padding-start 0 0;
text-align: right;
}
}
8 changes: 4 additions & 4 deletions src/lib/datepicker/calendar-table.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ describe('MdCalendarTable', () => {
expect(rowEls.length).toBe(2);
expect(labelEls.length).toBe(1);
expect(cellEls.length).toBe(11);
expect(rowEls[0].firstElementChild.classList.contains('mat-calendar-table-label')).toBe(
true, 'first cell should be the label');
expect(rowEls[0].firstElementChild.classList)
.toContain('mat-calendar-table-label', 'first cell should be the label');
expect(labelEls[0].getAttribute('colspan')).toBe('3');
});

Expand All @@ -80,8 +80,8 @@ describe('MdCalendarTable', () => {
todayElement.click();
fixture.detectChanges();

expect(todayElement.classList.contains('mat-calendar-table-selected')).toBe(
true, 'today should be selected');
expect(todayElement.classList)
.toContain('mat-calendar-table-selected', 'today should be selected');
});
});
});
Expand Down

0 comments on commit d9c7f0b

Please sign in to comment.