-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into fix/#43-not-sent-log
- Loading branch information
Showing
16 changed files
with
5,139 additions
and
6,064 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# formatYYYYMMDDHHMM | ||
|
||
check if date-related string is valid and returns into the form of `YYYY.MM.DD.HH.MM`. | ||
> check the validation using [date-fns](https://github.com/date-fns/date-fns)'s `isValid` function. | ||
## 매개변수 | ||
|
||
- `basedTime`: date-related string to be checked. | ||
|
||
## 반환값 | ||
|
||
- if the string is valid, returns the string in the form of `YYYY.MM.DD.HH.MM` | ||
- if not, returns `new Error('Invalid date format')` | ||
|
||
|
||
## Example | ||
|
||
```typescript | ||
console.log(formatYYYYMMDDHHMM('2024-06-14T03:12:32')); // 2024.06.14 03:12 | ||
|
||
console.log(formatYYYYMMDDHHMM('2024-13-14T00:00:00')); // Invalid date format | ||
console.log(formatYYYYMMDDHHMM('2024-06-32T00:00:00')); // Invalid date format | ||
console.log(formatYYYYMMDDHHMM('2024-06-14T25:00:00')); // Invalid date format | ||
console.log(formatYYYYMMDDHHMM('2024-06-14T00:70:00')); // Invalid date format | ||
console.log(formatYYYYMMDDHHMM('2024-06-14T:00:00')); // Invalid date format | ||
console.log(formatYYYYMMDDHHMM('2024-06-14T00::00')); // Invalid date format | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# formatYYYYMMDDHHMM | ||
|
||
주어진 날짜 관련 문자열이 올바른 형식인지 검사하고 `YYYY.MM.DD.HH.MM`의 형태로 반환합니다. | ||
> [date-fns](https://github.com/date-fns/date-fns)의 isValid 함수를 활용하여서 검사합니다. | ||
## 매개변수 | ||
|
||
- `basedTime`: 검사할 문자열입니다. | ||
|
||
## 반환값 | ||
|
||
- 문자열이 올바른 형식이라면, `YYYY.MM.DD.HH.MM` 형태의 문자열을 반환합니다. | ||
- 그렇지 않다면, `new Error('Invalid date format')`를 반환합니다. | ||
|
||
|
||
## Example | ||
|
||
```typescript | ||
console.log(formatYYYYMMDDHHMM('2024-06-14T03:12:32'); // 2024.06.14 03:12 | ||
|
||
console.log(formatYYYYMMDDHHMM('2024-13-14T00:00:00')); // Invalid date format | ||
console.log(formatYYYYMMDDHHMM('2024-06-32T00:00:00')); // Invalid date format | ||
console.log(formatYYYYMMDDHHMM('2024-06-14T25:00:00')); // Invalid date format | ||
console.log(formatYYYYMMDDHHMM('2024-06-14T00:70:00')); // Invalid date format | ||
console.log(formatYYYYMMDDHHMM('2024-06-14T:00:00')); // Invalid date format | ||
console.log(formatYYYYMMDDHHMM('2024-06-14T00::00')); // Invalid date format | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# @yourssu/eslint-config | ||
|
||
## 1.0.0 | ||
|
||
### Major Changes | ||
|
||
- b61ae7f: create @yourssu/eslint-config, @yourssu/prettier-config for code style |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# @yourssu/prettier-config | ||
|
||
## 1.0.0 | ||
|
||
### Major Changes | ||
|
||
- b61ae7f: create @yourssu/eslint-config, @yourssu/prettier-config for code style |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { describe, it, expect } from 'vitest'; | ||
|
||
import { formatYYYYMMDDHHMM } from './formatYYYYMMDDHHMM'; | ||
|
||
describe('formatYYYYMMDDHHMM', () => { | ||
it('should "2024-06-14T03:12:32" parsed to "2024.06.14 03:12".', () => { | ||
expect(formatYYYYMMDDHHMM('2024-06-14T03:12:32')).toEqual('2024.06.14 03:12'); | ||
}); | ||
|
||
it('should throw error when month is invalid.', () => { | ||
expect(() => formatYYYYMMDDHHMM('2024-13-14T00:00:00')).toThrowError('Invalid date format'); | ||
expect(() => formatYYYYMMDDHHMM('2024-24-14T00:00:00')).toThrowError('Invalid date format'); | ||
expect(() => formatYYYYMMDDHHMM('2024-31-14T00:00:00')).toThrowError('Invalid date format'); | ||
}); | ||
|
||
it('should throw error when day is invalid.', () => { | ||
expect(() => formatYYYYMMDDHHMM('2024-06-32T00:00:00')).toThrowError('Invalid date format'); | ||
expect(() => formatYYYYMMDDHHMM('2024-06-42T00:00:00')).toThrowError('Invalid date format'); | ||
expect(() => formatYYYYMMDDHHMM('2024-06-50T00:00:00')).toThrowError('Invalid date format'); | ||
}); | ||
|
||
it('should throw error when hour is invalid.', () => { | ||
expect(() => formatYYYYMMDDHHMM('2024-06-14T25:00:00')).toThrowError('Invalid date format'); | ||
expect(() => formatYYYYMMDDHHMM('2024-06-14T36:00:00')).toThrowError('Invalid date format'); | ||
expect(() => formatYYYYMMDDHHMM('2024-06-14T49:00:00')).toThrowError('Invalid date format'); | ||
}); | ||
|
||
it('should throw error when minute is invalid.', () => { | ||
expect(() => formatYYYYMMDDHHMM('2024-06-14T00:70:00')).toThrowError('Invalid date format'); | ||
expect(() => formatYYYYMMDDHHMM('2024-06-14T00:82:00')).toThrowError('Invalid date format'); | ||
expect(() => formatYYYYMMDDHHMM('2024-06-14T00:94:00')).toThrowError('Invalid date format'); | ||
}); | ||
|
||
it('should throw error when hour is missing.', () => { | ||
expect(() => formatYYYYMMDDHHMM('2024-06-14T:00:00')).toThrowError('Invalid date format'); | ||
}); | ||
|
||
it('should throw error when minute is missing.', () => { | ||
expect(() => formatYYYYMMDDHHMM('2024-06-14T00::00')).toThrowError('Invalid date format'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { isValid, getDate, getMonth, getYear, getHours, getMinutes } from 'date-fns'; | ||
|
||
export const formatYYYYMMDDHHMM = (basedTime: string): string => { | ||
const date = new Date(basedTime); | ||
|
||
if (isValid(date)) { | ||
return `${getYear(date).toString().padStart(2, '0')}.${(getMonth(date) + 1).toString().padStart(2, '0')}.${getDate(date).toString().padStart(2, '0')} ${getHours(date).toString().padStart(2, '0')}:${getMinutes(date).toString().padStart(2, '0')}`; | ||
} | ||
throw new Error('Invalid date format'); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.