Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into fix/#43-not-sent-log
Browse files Browse the repository at this point in the history
  • Loading branch information
owl1753 committed Jun 26, 2024
2 parents 3f3b3f1 + 6306171 commit 824e19a
Show file tree
Hide file tree
Showing 16 changed files with 5,139 additions and 6,064 deletions.
6 changes: 0 additions & 6 deletions .changeset/few-buses-behave.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/khaki-elephants-deliver.md

This file was deleted.

27 changes: 27 additions & 0 deletions apps/docs/src/pages/utils/formatYYYYMMDDHHMM.en.md
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
```
27 changes: 27 additions & 0 deletions apps/docs/src/pages/utils/formatYYYYMMDDHHMM.ko.md
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
```
7 changes: 7 additions & 0 deletions packages/eslint-config/CHANGELOG.md
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
2 changes: 1 addition & 1 deletion packages/eslint-config/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@yourssu/eslint-config",
"version": "0.1.0",
"version": "1.0.0",
"description": "Yourssu Eslint Config",
"main": "index.js",
"license": "MIT",
Expand Down
6 changes: 6 additions & 0 deletions packages/logging-system/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @yourssu/logging-system-react

## 1.1.1

### Patch Changes

- 515fd8d: refactor: crypto-js -> @yourssu/crypto migration

## 1.1.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/logging-system/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@yourssu/logging-system-react",
"private": false,
"version": "1.1.0",
"version": "1.1.1",
"description": "Yourssu Logging System for React",
"keywords": [
"yourssu",
Expand Down
7 changes: 7 additions & 0 deletions packages/prettier-config/CHANGELOG.md
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
2 changes: 1 addition & 1 deletion packages/prettier-config/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@yourssu/prettier-config",
"version": "0.1.0",
"version": "1.0.0",
"description": "Yourssu Prettier Config",
"main": "index.js",
"license": "MIT",
Expand Down
3 changes: 2 additions & 1 deletion packages/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"test": "vitest"
},
"devDependencies": {
"@types/node": "^20.14.2"
"@types/node": "^20.14.2",
"date-fns": "^3.6.0"
}
}
41 changes: 41 additions & 0 deletions packages/utils/src/formatYYYYMMDDHHMM.test.ts
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');
});
});
10 changes: 10 additions & 0 deletions packages/utils/src/formatYYYYMMDDHHMM.ts
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');
};
1 change: 1 addition & 0 deletions packages/utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ export { hasNumberAndEnglishWithSymbols } from './hasNumberAndEnglishWithSymbols
export { hasNumberOrEnglishOrHangulOrSpace } from './hasNumberOrEnglishOrHangulOrSpace.ts';
export { debounce } from './debounce.ts';
export { throttle } from './throttle.ts';
export { formatYYYYMMDDHHMM } from './formatYYYYMMDDHHMM.ts';
export { isEmail } from './isEmail.ts';
1 change: 1 addition & 0 deletions packages/utils/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export default defineConfig({
resolve: true,
},
external: ['react', 'react-dom'],
noExternal: ['date-fns'],
splitting: false,
clean: true,
sourcemap: true,
Expand Down
Loading

0 comments on commit 824e19a

Please sign in to comment.