@things-factory/work-shift 6.1.185 → 6.1.186

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/work-shift",
3
- "version": "6.1.185",
3
+ "version": "6.1.186",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "client/index.js",
6
6
  "things-factory": true,
@@ -24,10 +24,10 @@
24
24
  "migration:create": "node ../../node_modules/typeorm/cli.js migration:create -d ./server/migrations"
25
25
  },
26
26
  "dependencies": {
27
- "@things-factory/auth-base": "^6.1.185",
27
+ "@things-factory/auth-base": "^6.1.186",
28
28
  "@things-factory/env": "^6.1.175",
29
- "@things-factory/shell": "^6.1.182",
29
+ "@things-factory/shell": "^6.1.186",
30
30
  "moment-timezone": "^0.5.40"
31
31
  },
32
- "gitHead": "b6793ed8361e9fc5a4776fb48010007960ffdec8"
32
+ "gitHead": "ddf508496cdd7d4b9d0e020703a2f7a586a42ec5"
33
33
  }
@@ -1,250 +1,2 @@
1
- import moment from 'moment-timezone'
2
-
3
- import { logger } from '@things-factory/env'
4
- import { Domain, getRepository } from '@things-factory/shell'
5
-
6
- import { WorkShift, WorkShiftDateType } from '../service/work-shift/work-shift'
7
- import { WorkShiftInfo } from '../service/work-shift/work-shift-type'
8
-
9
- export async function getDateRangeForWorkShift(
10
- domain: Domain,
11
- workDate: string,
12
- workShiftName: string,
13
- options: { timezone?: string; format?: string }
14
- ): Promise<Date[]> {
15
- const dateOptions = { timezone: domain.timezone || 'UTC', format: 'YYYY-MM-DD', ...options }
16
- const { timezone, format } = dateOptions
17
-
18
- const workShift = await getRepository(WorkShift).findOne({
19
- where: {
20
- domain: { id: domain.id },
21
- name: workShiftName
22
- }
23
- })
24
-
25
- if (!workShift) {
26
- return
27
- }
28
- const theDay = moment.tz(workDate, timezone)
29
- const { name, fromDate, fromTime, toDate, toTime } = workShift
30
-
31
- const convertedFromDate = theDay.clone().add(fromDate, 'day')
32
- const convertedToDate = theDay.clone().add(toDate, 'day')
33
- const from = moment
34
- .tz(`${convertedFromDate.format('YYYY-MM-DD')} ${fromTime}`, 'YYYY-MM-DD HH:mm:ss', timezone)
35
- .toDate()
36
- const to = moment.tz(`${convertedToDate.format('YYYY-MM-DD')} ${toTime}`, 'YYYY-MM-DD HH:mm:ss', timezone).toDate()
37
-
38
- return [from, to]
39
- }
40
-
41
- export async function getDateRangeForWorkDate(
42
- domain: Domain,
43
- workDate: string,
44
- options: { timezone?: string; format?: string }
45
- ) {
46
- const dateOptions = { timezone: domain.timezone || 'UTC', format: 'YYYY-MM-DD', ...options }
47
- const { timezone, format } = dateOptions
48
-
49
- var beginDate
50
- var endDate
51
-
52
- /* 1. get work-shift list for the domain */
53
- const workShifts = await getRepository(WorkShift).find({
54
- where: {
55
- domain: { id: domain.id }
56
- },
57
- order: {
58
- fromDate: 'ASC',
59
- fromTime: 'ASC'
60
- }
61
- })
62
-
63
- /* 2. get date-time for every work-shift */
64
- if (workShifts && workShifts.length > 0) {
65
- const theDay = moment.tz(workDate, timezone)
66
-
67
- for (let j = 0; j < workShifts.length; j++) {
68
- const { name, fromDate, fromTime, toDate, toTime } = workShifts[j]
69
-
70
- const convertedFromDate = theDay.clone().add(fromDate, 'day')
71
- const convertedToDate = theDay.clone().add(toDate, 'day')
72
- const from = moment
73
- .tz(`${convertedFromDate.format('YYYY-MM-DD')} ${fromTime}`, 'YYYY-MM-DD HH:mm:ss', timezone)
74
- .toDate()
75
- const to = moment
76
- .tz(`${convertedToDate.format('YYYY-MM-DD')} ${toTime}`, 'YYYY-MM-DD HH:mm:ss', timezone)
77
- .toDate()
78
-
79
- if (!beginDate) {
80
- beginDate = from
81
- }
82
-
83
- endDate = to
84
- }
85
- } else {
86
- return
87
- }
88
-
89
- /* 3. in case there are no work-shift, just give date and default shift '' */
90
- return [beginDate, endDate]
91
- }
92
-
93
- export async function getWorkDateAndShift(domain: Domain, dateTime: Date, options?: any): Promise<WorkShiftInfo> {
94
- const dateOptions = { timezone: domain.timezone || 'UTC', format: 'YYYY-MM-DD', ...options }
95
- const { timezone, format } = dateOptions
96
-
97
- const givenDate = moment(dateTime).tz(timezone)
98
- /* 1. get work-shift list for the domain */
99
- const workShifts = await getRepository(WorkShift).find({
100
- where: {
101
- domain: { id: domain.id }
102
- },
103
- order: {
104
- fromDate: 'ASC',
105
- fromTime: 'ASC'
106
- }
107
- })
108
-
109
- /* 2. compare given date-time to every work-shift */
110
- const theDay = givenDate.clone().startOf('day')
111
- const theDayBefore = theDay.clone().subtract(1, 'day')
112
- const theDayAfter = theDay.clone().add(1, 'day')
113
-
114
- if (workShifts && workShifts.length > 0) {
115
- const days = [theDayBefore, theDay, theDayAfter]
116
- let dateBegin, dateEnd
117
-
118
- for (let i = 0; i < days.length; i++) {
119
- const day = days[i]
120
- dateBegin = null
121
-
122
- for (let j = 0; j < workShifts.length; j++) {
123
- const { name, fromDate, fromTime, toDate, toTime } = workShifts[j]
124
-
125
- const convertedFromDate = day.clone().add(fromDate, 'day')
126
- const convertedToDate = day.clone().add(toDate, 'day')
127
-
128
- const from = moment.tz(`${convertedFromDate.format('YYYY-MM-DD')} ${fromTime}`, 'YYYY-MM-DD HH:mm:ss', timezone)
129
- const to = moment.tz(`${convertedToDate.format('YYYY-MM-DD')} ${toTime}`, 'YYYY-MM-DD HH:mm:ss', timezone)
130
-
131
- dateBegin = dateBegin || from
132
- dateEnd = from.clone().add(1, 'day')
133
-
134
- if (dateTime >= from.toDate() && to.toDate() > dateTime) {
135
- return {
136
- workDate: moment(day).format(format),
137
- workShift: name,
138
- dateRange: [dateBegin.toDate(), dateEnd.toDate()],
139
- shiftRange: [from.toDate(), to.toDate()]
140
- }
141
- }
142
- }
143
- }
144
-
145
- logger.error(new Error('shift not found'))
146
- }
147
-
148
- /* 3. in case there are no work-shift, just give date and default shift '' */
149
- return {
150
- workDate: givenDate.format(format),
151
- workShift: '',
152
- dateRange: [theDay.toDate(), theDayAfter.toDate()]
153
- }
154
- }
155
-
156
- export async function getLatestWorkDateAndShift(domain: Domain, dateTime: Date, options?: any): Promise<WorkShiftInfo> {
157
- const dateOptions = { timezone: domain.timezone || 'UTC', format: 'YYYY-MM-DD', ...options }
158
- const { timezone, format } = dateOptions
159
-
160
- const givenDate = moment(dateTime).tz(timezone)
161
-
162
- /* 1. get work-shift list for the domain */
163
- const workShifts = await getRepository(WorkShift).find({
164
- where: {
165
- domain: { id: domain.id }
166
- },
167
- order: {
168
- fromDate: 'ASC',
169
- fromTime: 'ASC'
170
- }
171
- })
172
-
173
- /* 2. compare given date-time to every work-shift */
174
- const theDay = givenDate.clone().startOf('day')
175
- const theDayBefore = theDay.clone().subtract(1, 'day')
176
- const theDayAfter = theDay.clone().add(1, 'day')
177
-
178
- if (workShifts && workShifts.length > 0) {
179
- const days = [theDayBefore, theDay, theDayAfter]
180
- let dateBegin, dateEnd
181
-
182
- for (let i = 0; i < days.length; i++) {
183
- const day = days[i]
184
- dateBegin = null
185
-
186
- for (let j = 0; j < workShifts.length; j++) {
187
- const { name, fromDate, fromTime, toDate, toTime } = workShifts[j]
188
-
189
- const convertedFromDate = day.clone().add(fromDate, 'day')
190
- const convertedToDate = day.clone().add(toDate, 'day')
191
-
192
- const from = moment.tz(`${convertedFromDate.format('YYYY-MM-DD')} ${fromTime}`, 'YYYY-MM-DD HH:mm:ss', timezone)
193
- const to = moment.tz(`${convertedToDate.format('YYYY-MM-DD')} ${toTime}`, 'YYYY-MM-DD HH:mm:ss', timezone)
194
-
195
- dateBegin = dateBegin || from
196
- dateEnd = from.clone().add(1, 'day')
197
-
198
- if (dateTime < from.toDate()) {
199
- if (j > 0) {
200
- const { name, fromDate, fromTime, toDate, toTime } = workShifts[j - 1]
201
-
202
- const from = moment.tz(
203
- `${convertedFromDate.format('YYYY-MM-DD')} ${fromTime}`,
204
- 'YYYY-MM-DD HH:mm:ss',
205
- timezone
206
- )
207
- const to = moment.tz(`${convertedToDate.format('YYYY-MM-DD')} ${toTime}`, 'YYYY-MM-DD HH:mm:ss', timezone)
208
-
209
- return {
210
- workDate: moment(day).format(format),
211
- workShift: name,
212
- dateRange: [dateBegin.toDate(), dateEnd.toDate()],
213
- shiftRange: [from.toDate(), to.toDate()]
214
- }
215
- } else if (i > 0) {
216
- const { name, fromDate, fromTime, toDate, toTime } = workShifts[0]
217
-
218
- const convertedFromDate = days[i - 1].clone().add(fromDate, 'day')
219
- const convertedToDate = days[i - 1].clone().add(toDate, 'day')
220
-
221
- const from = moment.tz(
222
- `${convertedFromDate.format('YYYY-MM-DD')} ${fromTime}`,
223
- 'YYYY-MM-DD HH:mm:ss',
224
- timezone
225
- )
226
- const to = moment.tz(`${convertedToDate.format('YYYY-MM-DD')} ${toTime}`, 'YYYY-MM-DD HH:mm:ss', timezone)
227
-
228
- return {
229
- workDate: moment(day).format(format),
230
- workShift: name,
231
- dateRange: [dateBegin.clone().subtract(1, 'day').toDate(), dateBegin.toDate()],
232
- shiftRange: [from.toDate(), to.toDate()]
233
- }
234
- } else {
235
- return
236
- }
237
- }
238
- }
239
- }
240
-
241
- logger.error(new Error('shift not found'))
242
- }
243
-
244
- /* 3. in case there are no work-shift, just give date and default shift '' */
245
- return {
246
- workDate: givenDate.clone().subtract(1, 'day').format(format),
247
- workShift: '',
248
- dateRange: [theDayBefore.toDate(), theDay.toDate()]
249
- }
250
- }
1
+ export * from './work-shift-range'
2
+ export * from './work-shift-schedule'
@@ -0,0 +1,250 @@
1
+ import moment from 'moment-timezone'
2
+
3
+ import { logger } from '@things-factory/env'
4
+ import { Domain, getRepository } from '@things-factory/shell'
5
+
6
+ import { WorkShift } from '../service/work-shift/work-shift'
7
+ import { WorkShiftInfo } from '../service/work-shift/work-shift-type'
8
+
9
+ export async function getDateRangeForWorkShift(
10
+ domain: Domain,
11
+ workDate: string,
12
+ workShiftName: string,
13
+ options: { timezone?: string; format?: string }
14
+ ): Promise<Date[]> {
15
+ const dateOptions = { timezone: domain.timezone || 'UTC', format: 'YYYY-MM-DD', ...options }
16
+ const { timezone, format } = dateOptions
17
+
18
+ const workShift = await getRepository(WorkShift).findOne({
19
+ where: {
20
+ domain: { id: domain.id },
21
+ name: workShiftName
22
+ }
23
+ })
24
+
25
+ if (!workShift) {
26
+ return
27
+ }
28
+ const theDay = moment.tz(workDate, timezone)
29
+ const { name, fromDate, fromTime, toDate, toTime } = workShift
30
+
31
+ const convertedFromDate = theDay.clone().add(fromDate, 'day')
32
+ const convertedToDate = theDay.clone().add(toDate, 'day')
33
+ const from = moment
34
+ .tz(`${convertedFromDate.format('YYYY-MM-DD')} ${fromTime}`, 'YYYY-MM-DD HH:mm:ss', timezone)
35
+ .toDate()
36
+ const to = moment.tz(`${convertedToDate.format('YYYY-MM-DD')} ${toTime}`, 'YYYY-MM-DD HH:mm:ss', timezone).toDate()
37
+
38
+ return [from, to]
39
+ }
40
+
41
+ export async function getDateRangeForWorkDate(
42
+ domain: Domain,
43
+ workDate: string,
44
+ options: { timezone?: string; format?: string }
45
+ ) {
46
+ const dateOptions = { timezone: domain.timezone || 'UTC', format: 'YYYY-MM-DD', ...options }
47
+ const { timezone, format } = dateOptions
48
+
49
+ var beginDate
50
+ var endDate
51
+
52
+ /* 1. get work-shift list for the domain */
53
+ const workShifts = await getRepository(WorkShift).find({
54
+ where: {
55
+ domain: { id: domain.id }
56
+ },
57
+ order: {
58
+ fromDate: 'ASC',
59
+ fromTime: 'ASC'
60
+ }
61
+ })
62
+
63
+ /* 2. get date-time for every work-shift */
64
+ if (workShifts && workShifts.length > 0) {
65
+ const theDay = moment.tz(workDate, timezone)
66
+
67
+ for (let j = 0; j < workShifts.length; j++) {
68
+ const { name, fromDate, fromTime, toDate, toTime } = workShifts[j]
69
+
70
+ const convertedFromDate = theDay.clone().add(fromDate, 'day')
71
+ const convertedToDate = theDay.clone().add(toDate, 'day')
72
+ const from = moment
73
+ .tz(`${convertedFromDate.format('YYYY-MM-DD')} ${fromTime}`, 'YYYY-MM-DD HH:mm:ss', timezone)
74
+ .toDate()
75
+ const to = moment
76
+ .tz(`${convertedToDate.format('YYYY-MM-DD')} ${toTime}`, 'YYYY-MM-DD HH:mm:ss', timezone)
77
+ .toDate()
78
+
79
+ if (!beginDate) {
80
+ beginDate = from
81
+ }
82
+
83
+ endDate = to
84
+ }
85
+ } else {
86
+ return
87
+ }
88
+
89
+ /* 3. in case there are no work-shift, just give date and default shift '' */
90
+ return [beginDate, endDate]
91
+ }
92
+
93
+ export async function getWorkDateAndShift(domain: Domain, dateTime: Date, options?: any): Promise<WorkShiftInfo> {
94
+ const dateOptions = { timezone: domain.timezone || 'UTC', format: 'YYYY-MM-DD', ...options }
95
+ const { timezone, format } = dateOptions
96
+
97
+ const givenDate = moment(dateTime).tz(timezone)
98
+ /* 1. get work-shift list for the domain */
99
+ const workShifts = await getRepository(WorkShift).find({
100
+ where: {
101
+ domain: { id: domain.id }
102
+ },
103
+ order: {
104
+ fromDate: 'ASC',
105
+ fromTime: 'ASC'
106
+ }
107
+ })
108
+
109
+ /* 2. compare given date-time to every work-shift */
110
+ const theDay = givenDate.clone().startOf('day')
111
+ const theDayBefore = theDay.clone().subtract(1, 'day')
112
+ const theDayAfter = theDay.clone().add(1, 'day')
113
+
114
+ if (workShifts && workShifts.length > 0) {
115
+ const days = [theDayBefore, theDay, theDayAfter]
116
+ let dateBegin, dateEnd
117
+
118
+ for (let i = 0; i < days.length; i++) {
119
+ const day = days[i]
120
+ dateBegin = null
121
+
122
+ for (let j = 0; j < workShifts.length; j++) {
123
+ const { name, fromDate, fromTime, toDate, toTime } = workShifts[j]
124
+
125
+ const convertedFromDate = day.clone().add(fromDate, 'day')
126
+ const convertedToDate = day.clone().add(toDate, 'day')
127
+
128
+ const from = moment.tz(`${convertedFromDate.format('YYYY-MM-DD')} ${fromTime}`, 'YYYY-MM-DD HH:mm:ss', timezone)
129
+ const to = moment.tz(`${convertedToDate.format('YYYY-MM-DD')} ${toTime}`, 'YYYY-MM-DD HH:mm:ss', timezone)
130
+
131
+ dateBegin = dateBegin || from
132
+ dateEnd = from.clone().add(1, 'day')
133
+
134
+ if (dateTime >= from.toDate() && to.toDate() > dateTime) {
135
+ return {
136
+ workDate: moment(day).format(format),
137
+ workShift: name,
138
+ dateRange: [dateBegin.toDate(), dateEnd.toDate()],
139
+ shiftRange: [from.toDate(), to.toDate()]
140
+ }
141
+ }
142
+ }
143
+ }
144
+
145
+ logger.error(new Error('shift not found'))
146
+ }
147
+
148
+ /* 3. in case there are no work-shift, just give date and default shift '' */
149
+ return {
150
+ workDate: givenDate.format(format),
151
+ workShift: '',
152
+ dateRange: [theDay.toDate(), theDayAfter.toDate()]
153
+ }
154
+ }
155
+
156
+ export async function getLatestWorkDateAndShift(domain: Domain, dateTime: Date, options?: any): Promise<WorkShiftInfo> {
157
+ const dateOptions = { timezone: domain.timezone || 'UTC', format: 'YYYY-MM-DD', ...options }
158
+ const { timezone, format } = dateOptions
159
+
160
+ const givenDate = moment(dateTime).tz(timezone)
161
+
162
+ /* 1. get work-shift list for the domain */
163
+ const workShifts = await getRepository(WorkShift).find({
164
+ where: {
165
+ domain: { id: domain.id }
166
+ },
167
+ order: {
168
+ fromDate: 'ASC',
169
+ fromTime: 'ASC'
170
+ }
171
+ })
172
+
173
+ /* 2. compare given date-time to every work-shift */
174
+ const theDay = givenDate.clone().startOf('day')
175
+ const theDayBefore = theDay.clone().subtract(1, 'day')
176
+ const theDayAfter = theDay.clone().add(1, 'day')
177
+
178
+ if (workShifts && workShifts.length > 0) {
179
+ const days = [theDayBefore, theDay, theDayAfter]
180
+ let dateBegin, dateEnd
181
+
182
+ for (let i = 0; i < days.length; i++) {
183
+ const day = days[i]
184
+ dateBegin = null
185
+
186
+ for (let j = 0; j < workShifts.length; j++) {
187
+ const { name, fromDate, fromTime, toDate, toTime } = workShifts[j]
188
+
189
+ const convertedFromDate = day.clone().add(fromDate, 'day')
190
+ const convertedToDate = day.clone().add(toDate, 'day')
191
+
192
+ const from = moment.tz(`${convertedFromDate.format('YYYY-MM-DD')} ${fromTime}`, 'YYYY-MM-DD HH:mm:ss', timezone)
193
+ const to = moment.tz(`${convertedToDate.format('YYYY-MM-DD')} ${toTime}`, 'YYYY-MM-DD HH:mm:ss', timezone)
194
+
195
+ dateBegin = dateBegin || from
196
+ dateEnd = from.clone().add(1, 'day')
197
+
198
+ if (dateTime < from.toDate()) {
199
+ if (j > 0) {
200
+ const { name, fromDate, fromTime, toDate, toTime } = workShifts[j - 1]
201
+
202
+ const from = moment.tz(
203
+ `${convertedFromDate.format('YYYY-MM-DD')} ${fromTime}`,
204
+ 'YYYY-MM-DD HH:mm:ss',
205
+ timezone
206
+ )
207
+ const to = moment.tz(`${convertedToDate.format('YYYY-MM-DD')} ${toTime}`, 'YYYY-MM-DD HH:mm:ss', timezone)
208
+
209
+ return {
210
+ workDate: moment(day).format(format),
211
+ workShift: name,
212
+ dateRange: [dateBegin.toDate(), dateEnd.toDate()],
213
+ shiftRange: [from.toDate(), to.toDate()]
214
+ }
215
+ } else if (i > 0) {
216
+ const { name, fromDate, fromTime, toDate, toTime } = workShifts[0]
217
+
218
+ const convertedFromDate = days[i - 1].clone().add(fromDate, 'day')
219
+ const convertedToDate = days[i - 1].clone().add(toDate, 'day')
220
+
221
+ const from = moment.tz(
222
+ `${convertedFromDate.format('YYYY-MM-DD')} ${fromTime}`,
223
+ 'YYYY-MM-DD HH:mm:ss',
224
+ timezone
225
+ )
226
+ const to = moment.tz(`${convertedToDate.format('YYYY-MM-DD')} ${toTime}`, 'YYYY-MM-DD HH:mm:ss', timezone)
227
+
228
+ return {
229
+ workDate: moment(day).format(format),
230
+ workShift: name,
231
+ dateRange: [dateBegin.clone().subtract(1, 'day').toDate(), dateBegin.toDate()],
232
+ shiftRange: [from.toDate(), to.toDate()]
233
+ }
234
+ } else {
235
+ return
236
+ }
237
+ }
238
+ }
239
+ }
240
+
241
+ logger.error(new Error('shift not found'))
242
+ }
243
+
244
+ /* 3. in case there are no work-shift, just give date and default shift '' */
245
+ return {
246
+ workDate: givenDate.clone().subtract(1, 'day').format(format),
247
+ workShift: '',
248
+ dateRange: [theDayBefore.toDate(), theDay.toDate()]
249
+ }
250
+ }
@@ -0,0 +1,79 @@
1
+ import { Domain, getRepository } from '@things-factory/shell'
2
+
3
+ import { WorkShift } from '../service/work-shift/work-shift'
4
+
5
+ export async function getSummaryScheduleForWorkShift(domain: Domain): Promise<string> {
6
+ const workShifts = await getRepository(WorkShift).find({
7
+ where: {
8
+ domain: { id: domain.id }
9
+ }
10
+ })
11
+
12
+ if (!workShifts || workShifts.length == 0) {
13
+ return ''
14
+ }
15
+
16
+ const hours = workShifts
17
+ .map(workShift => workShift.toTime)
18
+ .map(getNextHourIn24HourFormat)
19
+ .join(',')
20
+
21
+ return `10 ${hours} * * * *`
22
+ }
23
+
24
+ export async function getSummaryScheduleForWorkDate(domain: Domain): Promise<string> {
25
+ /* 1. 도메인의 워크시프트를 모두 가져온다. */
26
+ const workShifts = await getRepository(WorkShift).find({
27
+ where: {
28
+ domain: { id: domain.id }
29
+ },
30
+ order: {
31
+ fromDate: 'ASC',
32
+ fromTime: 'ASC'
33
+ }
34
+ })
35
+
36
+ /* 2. 워크데이의 마지막 시간을 구한 뒤, 그 30분뒤 시간에 매일 수행하는 crontab을 계산한다. */
37
+ if (workShifts && workShifts.length > 0) {
38
+ const { toTime } = workShifts[workShifts.length - 1]
39
+ return timePlusThirtyMinutesToCron(toTime)
40
+ } else {
41
+ return
42
+ }
43
+ }
44
+
45
+ function timePlusThirtyMinutesToCron(time: string): string {
46
+ const isPM = time.toUpperCase().includes('PM')
47
+ const [hours, minutes] = time
48
+ .toUpperCase()
49
+ .replace(/(AM|PM)/, '')
50
+ .split(':')
51
+ .map(Number)
52
+
53
+ // 기준 날짜와 시간 정보를 사용하여 Date 객체를 생성합니다.
54
+ let date = new Date(1970, 0, 1, isPM ? (hours % 12) + 12 : hours % 12, minutes)
55
+
56
+ // 30분을 추가합니다.
57
+ date.setMinutes(date.getMinutes() + 30)
58
+
59
+ // 결과 시간을 얻습니다.
60
+ const resultHours = String(date.getHours()).padStart(2, '0')
61
+ const resultMinutes = String(date.getMinutes()).padStart(2, '0')
62
+
63
+ // 결과 시간을 사용하여 crontab 항목을 반환합니다.
64
+ return `${resultMinutes} ${resultHours} * * * *`
65
+ }
66
+
67
+ function getNextHourIn24HourFormat(time: string): string {
68
+ const isPM = time.toUpperCase().includes('PM')
69
+ const hours = Number(time.split(':')[0])
70
+
71
+ // 기준 날짜와 시간 정보를 사용하여 Date 객체를 생성합니다.
72
+ let date = new Date(1970, 0, 1, isPM ? (hours % 12) + 12 : hours % 12, 0)
73
+
74
+ // 시간 값을 1 증가시킵니다.
75
+ date.setHours(date.getHours() + 1)
76
+
77
+ // 결과 시간을 얻습니다.
78
+ return String(date.getHours()).padStart(2, '0')
79
+ }