Skip to content

Commit

Permalink
Merge pull request #1177 from ORCID/pad-month-numbers
Browse files Browse the repository at this point in the history
Pad month numbers
  • Loading branch information
bobcaprice authored May 7, 2024
2 parents 93a9189 + 88a6a1e commit 42e43ab
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class AddConsortiumMemberComponent implements OnInit {
routeData: any
currentMonth: number | undefined
currentYear: number | undefined
monthList: [number, string][] | undefined
monthList: [string, string][] | undefined
yearList: number[] | undefined
editForm: FormGroup = this.fb.group({
orgName: [null, [Validators.required, Validators.maxLength(41)]],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class RemoveConsortiumMemberComponent implements OnInit, OnDestroy {
consortiumMemberId: string | undefined
currentMonth: number | undefined
currentYear: number | undefined
monthList: [number, string][] | undefined
monthList: [string, string][] | undefined
yearList: number[] | undefined
editForm: FormGroup = this.fb.group({
terminationMonth: [null, [Validators.required]],
Expand All @@ -55,6 +55,7 @@ export class RemoveConsortiumMemberComponent implements OnInit, OnDestroy {
this.currentMonth = this.dateUtilService.getCurrentMonthNumber()
this.currentYear = this.dateUtilService.getCurrentYear()
this.monthList = this.dateUtilService.getMonthsList()

this.yearList = this.dateUtilService.getFutureYearsIncludingCurrent(1)

this.accountService.getAccountData().subscribe((account) => {
Expand Down
8 changes: 4 additions & 4 deletions ui/src/app/shared/service/date-util.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,22 @@ export class DateUtilService {
return years
}

getMonthsList(): [number, string][] {
getMonthsList(): [string, string][] {
const months = moment.months()
const monthsArray = []
for (let _i = 1; _i <= months.length; _i++) {
const res: [number, string] = [parseInt(('0' + _i.toString()).slice(-2)), months[_i - 1]]
const res: [string, string] = [('0' + _i.toString()).slice(-2), months[_i - 1]]
monthsArray.push(res)
}
return monthsArray
}

getFutureMonthsList(): [number, string][] {
getFutureMonthsList(): [string, string][] {
const months = moment.months()
const monthsArray = []
for (let _i = 1; _i <= months.length; _i++) {
if (_i > this.getCurrentMonthNumber()) {
const res: [number, string] = [parseInt(('0' + _i.toString()).slice(-2)), months[_i - 1]]
const res: [string, string] = [('0' + _i.toString()).slice(-2), months[_i - 1]]
monthsArray.push(res)
}
}
Expand Down

0 comments on commit 42e43ab

Please sign in to comment.