Open
修复评论日期显示问题;update repository URL from gitee.com to gitcode.com #1
zhouyixingAdd on Jan 29
修复评论日期显示问题;update repository URL from gitee.com to gitcode.com #1
Open
Total: 2 files changed+11-3
| @@ -1,10 +1,10 @@ | |||
| 1 | -{ | 1 | +{ |
| 2 | "name": "@ohos_samples/imagecommentlibrary", | 2 | "name": "@ohos_samples/imagecommentlibrary", |
| 3 | "version": "1.0.0", | 3 | "version": "1.0.0", |
| 4 | "description": "This sample shows how to post a comment on an image by starting the system camera.", | 4 | "description": "This sample shows how to post a comment on an image by starting the system camera.", |
| 5 | "main": "Index.ets", | 5 | "main": "Index.ets", |
| 6 | "author": "@ohos_samples", | 6 | "author": "@ohos_samples", |
| 7 | "license": "Apache-2.0", | 7 | "license": "Apache-2.0", |
| 8 | - "repository": "https://gitee.com/harmonyos_samples/image-comment/tree/br_release_hmos", | 8 | + "repository": "https://gitcode.com/HarmonyOS_Samples/image-comment/tree/br_release_hmos", |
| 9 | "dependencies": {} | 9 | "dependencies": {} |
| 10 | } | 10 | } |
| @@ -54,9 +54,17 @@ export struct ImageCommentComponent { | |||
| 54 | this.commentList.addDataFirst(comment); | 54 | this.commentList.addDataFirst(comment); |
| 55 | } | 55 | } |
| 56 | 56 | ||
| 57 | + private padZero(num: number): string { | ||
| 58 | + return num < 10 ? `0${num}` : `${num}`; | ||
| 59 | + } | ||
| 60 | + | ||
| 57 | getCurrentDate(): string { | 61 | getCurrentDate(): string { |
| 58 | const date: Date = new Date(); | 62 | const date: Date = new Date(); |
| 59 | - return `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()} ${date.getHours()}:${date.getMinutes()}`; | 63 | + const month = this.padZero(date.getMonth() + 1); |
| 64 | + const day = this.padZero(date.getDate()); | ||
| 65 | + const hours = this.padZero(date.getHours()); | ||
| 66 | + const minutes = this.padZero(date.getMinutes()); | ||
| 67 | + return `${date.getFullYear()}-${month}-${day} ${hours}:${minutes}`; | ||
| 60 | } | 68 | } |
| 61 | 69 | ||
| 62 | build() { | 70 | build() { |