( src: Entity, serviceType: SUPPORTED_SERVICES_TYPE )
| 46 | } from "./localdb"; |
| 47 | |
| 48 | const copyEntityAndFixTimeFormat = ( |
| 49 | src: Entity, |
| 50 | serviceType: SUPPORTED_SERVICES_TYPE |
| 51 | ) => { |
| 52 | const result = Object.assign({}, src); |
| 53 | if (result.mtimeCli !== undefined) { |
| 54 | if (result.mtimeCli === 0) { |
| 55 | result.mtimeCli = undefined; |
| 56 | } else { |
| 57 | if (serviceType === "s3" || serviceType === "dropbox") { |
| 58 | // round to second instead of millisecond |
| 59 | result.mtimeCli = Math.floor(result.mtimeCli / 1000.0) * 1000; |
| 60 | } |
| 61 | result.mtimeCliFmt = unixTimeToStr(result.mtimeCli); |
| 62 | } |
| 63 | } |
| 64 | if (result.ctimeCli !== undefined) { |
| 65 | if (result.ctimeCli === 0) { |
| 66 | result.ctimeCli = undefined; |
| 67 | } else { |
| 68 | if (serviceType === "s3" || serviceType === "dropbox") { |
| 69 | // round to second instead of millisecond |
| 70 | result.ctimeCli = Math.floor(result.ctimeCli / 1000.0) * 1000; |
| 71 | } |
| 72 | result.ctimeCliFmt = unixTimeToStr(result.ctimeCli); |
| 73 | } |
| 74 | } |
| 75 | if (result.mtimeSvr !== undefined) { |
| 76 | if (result.mtimeSvr === 0) { |
| 77 | result.mtimeSvr = undefined; |
| 78 | } else { |
| 79 | if (serviceType === "s3" || serviceType === "dropbox") { |
| 80 | // round to second instead of millisecond |
| 81 | result.mtimeSvr = Math.floor(result.mtimeSvr / 1000.0) * 1000; |
| 82 | } |
| 83 | result.mtimeSvrFmt = unixTimeToStr(result.mtimeSvr); |
| 84 | } |
| 85 | } |
| 86 | if (result.prevSyncTime !== undefined) { |
| 87 | if (result.prevSyncTime === 0) { |
| 88 | result.prevSyncTime = undefined; |
| 89 | } else { |
| 90 | if (serviceType === "s3" || serviceType === "dropbox") { |
| 91 | // round to second instead of millisecond |
| 92 | result.prevSyncTime = Math.floor(result.prevSyncTime / 1000.0) * 1000; |
| 93 | } |
| 94 | result.prevSyncTimeFmt = unixTimeToStr(result.prevSyncTime); |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | return result; |
| 99 | }; |
| 100 | |
| 101 | /** |
| 102 | * Directly throw error here. |
no test coverage detected