Socialify

Folder ..

Viewing useTIme.ts
35 lines (30 loc) • 785.0 B

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
export const date = new Date();

export const time = new Date().getTime();

export const year = new Date().getFullYear();

export const month = new Date().getMonth();

export const getCurrentSeason = (): string => {
  if (month >= 2 && month <= 4) {
    return 'SPRING';
  } else if (month >= 5 && month <= 7) {
    return 'SUMMER';
  } else if (month >= 8 && month <= 10) {
    return 'FALL';
  } else {
    return 'WINTER';
  }
};

export const getNextSeason = (): string => {
  const currentSeason = getCurrentSeason();
  switch (currentSeason) {
    case 'SPRING':
      return 'SUMMER';
    case 'SUMMER':
      return 'FALL';
    case 'FALL':
      return 'WINTER';
    case 'WINTER':
      return 'SPRING';
    default:
      return 'UNKNOWN'; // Should never be reached
  }
};