Skip to content

Commit

Permalink
[easy] Clean up util functions (#561)
Browse files Browse the repository at this point in the history
* util cleanup

* util cleanup
  • Loading branch information
benjamin-shen authored Oct 29, 2021
1 parent 97d94cc commit fa383c8
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/components/Modals/Onboarding/OnboardingBasic.vue
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
<script lang="ts">
import { PropType, defineComponent } from 'vue';
import reqsData from '@/requirements/typed-requirement-json';
import { clickOutside } from '@/utilities';
import { clickOutside, getCurrentYear } from '@/utilities';
import OnboardingBasicMultiDropdown from './OnboardingBasicMultiDropdown.vue';
import OnboardingBasicSingleDropdown from './OnboardingBasicSingleDropdown.vue';
Expand Down Expand Up @@ -233,7 +233,7 @@ export default defineComponent({
semesters(): Readonly<Record<string, string>> {
const semsDict: Record<string, string> = {};
const yearRange = 6;
const curYear = new Date().getFullYear();
const curYear = getCurrentYear();
for (let i = -yearRange; i <= yearRange; i += 1) {
const yr = String(curYear + i);
semsDict[yr] = yr;
Expand Down
6 changes: 3 additions & 3 deletions src/components/Modals/SelectSemester.vue
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@

<script lang="ts">
import { PropType, defineComponent } from 'vue';
import { getCurrentSeason, clickOutside } from '@/utilities';
import { getCurrentSeason, getCurrentYear, clickOutside } from '@/utilities';
import store from '@/store';
import fall from '@/assets/images/fallEmoji.svg';
Expand Down Expand Up @@ -145,7 +145,7 @@ export default defineComponent({
},
data(): Data {
// years
const currentYear = new Date().getFullYear();
const currentYear = getCurrentYear();
const seasons: readonly (readonly [string, FirestoreSemesterSeason])[] = [
[fall, 'Fall'],
[spring, 'Spring'],
Expand Down Expand Up @@ -194,7 +194,7 @@ export default defineComponent({
return this.seasonText || this.season || defaultSeason;
},
yearPlaceholder(): string {
let defaultYear = String(new Date().getFullYear());
let defaultYear = String(getCurrentYear());
if (this.isCourseModelSelectingSemester) {
defaultYear = 'Select';
}
Expand Down
6 changes: 3 additions & 3 deletions src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import computeGroupedRequirementFulfillmentReports from './requirements/requirem
import RequirementFulfillmentGraph from './requirements/requirement-graph';
import { createAppOnboardingData } from './user-data-converter';
import {
sortedSemesters,
getCurrentSeason,
allocateAllSubjectColor,
checkNotNull,
getCurrentSeason,
getCurrentYear,
allocateAllSubjectColor,
sortedSemesters,
} from './utilities';

type SimplifiedFirebaseUser = { readonly displayName: string; readonly email: string };
Expand Down
6 changes: 0 additions & 6 deletions src/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,6 @@ export function getCurrentYear(): number {
return new Date().getFullYear();
}

export function getCurrentYearSuffix(): string {
// If current year is 2020, get string '20'
const currentYear = new Date().getFullYear();
return currentYear.toString().substring(2);
}

export function getCollegeFullName(acronym: string | undefined): string {
// Return empty string if college is not in requirementJSON
const college = acronym ? requirementJSON.college[acronym] : null;
Expand Down

0 comments on commit fa383c8

Please sign in to comment.