Showing
1 changed file
with
30 additions
and
3 deletions
| @@ -496,7 +496,6 @@ struct ReserveMorePage { | @@ -496,7 +496,6 @@ struct ReserveMorePage { | ||
| 496 | } | 496 | } |
| 497 | } | 497 | } |
| 498 | } | 498 | } |
| 499 | - | ||
| 500 | getReserveDate(eventDateTimeString: string, type: number): string { | 499 | getReserveDate(eventDateTimeString: string, type: number): string { |
| 501 | // 解析事件的日期和时间 | 500 | // 解析事件的日期和时间 |
| 502 | const eventDateTime = new Date(eventDateTimeString); | 501 | const eventDateTime = new Date(eventDateTimeString); |
| @@ -509,11 +508,14 @@ struct ReserveMorePage { | @@ -509,11 +508,14 @@ struct ReserveMorePage { | ||
| 509 | 508 | ||
| 510 | if (type === 1) { | 509 | if (type === 1) { |
| 511 | // 如果是今天 | 510 | // 如果是今天 |
| 512 | - if (eventDateTime.setHours(0,0,0,0) === currentDateTime.setHours(0,0,0,0)) { | 511 | + const eventDate = eventDateTime.setHours(0, 0, 0, 0); |
| 512 | + const currentDate = currentDateTime.setHours(0, 0, 0, 0); | ||
| 513 | + if (eventDate === currentDate) { | ||
| 513 | return `今天`; | 514 | return `今天`; |
| 514 | } else { | 515 | } else { |
| 515 | // 如果事件不在今天 | 516 | // 如果事件不在今天 |
| 516 | - const month = eventDateTime.getMonth() + 1; // 月份从0开始 | 517 | + // 将来的日期 |
| 518 | + const month = eventDateTime.getMonth() + 1; | ||
| 517 | const date = eventDateTime.getDate(); | 519 | const date = eventDateTime.getDate(); |
| 518 | return `${month}月${date}日`; | 520 | return `${month}月${date}日`; |
| 519 | } | 521 | } |
| @@ -522,5 +524,30 @@ struct ReserveMorePage { | @@ -522,5 +524,30 @@ struct ReserveMorePage { | ||
| 522 | } | 524 | } |
| 523 | } | 525 | } |
| 524 | 526 | ||
| 527 | + // getReserveDate(eventDateTimeString: string, type: number): string { | ||
| 528 | + // // 解析事件的日期和时间 | ||
| 529 | + // const eventDateTime = new Date(eventDateTimeString); | ||
| 530 | + // const currentDateTime = new Date(); | ||
| 531 | + // | ||
| 532 | + // // 截取事件时间的小时和分钟(假设事件时间是按照24小时制) | ||
| 533 | + // const eventHour = eventDateTime.getHours(); | ||
| 534 | + // const eventMinutes = eventDateTime.getMinutes(); | ||
| 535 | + // const eventTimeStr = `${eventHour}:${eventMinutes.toString().padStart(2, '0')}开始`; // 格式化时间,确保分钟是两位数 | ||
| 536 | + // | ||
| 537 | + // if (type === 1) { | ||
| 538 | + // // 如果是今天 | ||
| 539 | + // if (eventDateTime.setHours(0,0,0,0) === currentDateTime.setHours(0,0,0,0)) { | ||
| 540 | + // return `今天`; | ||
| 541 | + // } else { | ||
| 542 | + // // 如果事件不在今天 | ||
| 543 | + // const month = eventDateTime.getMonth() + 1; // 月份从0开始 | ||
| 544 | + // const date = eventDateTime.getDate(); | ||
| 545 | + // return `${month}月${date}日`; | ||
| 546 | + // } | ||
| 547 | + // } else { | ||
| 548 | + // return `${eventTimeStr}`; | ||
| 549 | + // } | ||
| 550 | + // } | ||
| 551 | + | ||
| 525 | 552 | ||
| 526 | } | 553 | } |
-
Please register or login to post a comment