mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-25 01:39:53 +00:00
update month passed calculation (#3063)
Signed-off-by: Ruslan Bayandinov <wazsone@ya.ru>
This commit is contained in:
parent
bf6dc4b207
commit
4b6030d11f
@ -32,6 +32,17 @@
|
|||||||
|
|
||||||
let time: string = ''
|
let time: string = ''
|
||||||
|
|
||||||
|
function calculateMonthsPassed (now: number, value: number): number {
|
||||||
|
const startDate: Date = new Date(value)
|
||||||
|
const endDate: Date = new Date(now)
|
||||||
|
const startYear = startDate.getFullYear()
|
||||||
|
const startMonth = startDate.getMonth()
|
||||||
|
const endYear = endDate.getFullYear()
|
||||||
|
const endMonth = endDate.getMonth()
|
||||||
|
|
||||||
|
return (endYear - startYear) * 12 + (endMonth - startMonth)
|
||||||
|
}
|
||||||
|
|
||||||
async function formatTime (now: number, value: number) {
|
async function formatTime (now: number, value: number) {
|
||||||
let passed = now - value
|
let passed = now - value
|
||||||
if (passed < 0) passed = 0
|
if (passed < 0) passed = 0
|
||||||
@ -42,7 +53,7 @@
|
|||||||
} else if (passed < MONTH) {
|
} else if (passed < MONTH) {
|
||||||
time = await translate(ui.string.Days, { days: Math.floor(passed / DAY) })
|
time = await translate(ui.string.Days, { days: Math.floor(passed / DAY) })
|
||||||
} else if (passed < YEAR) {
|
} else if (passed < YEAR) {
|
||||||
time = await translate(ui.string.Months, { months: Math.floor(passed / MONTH) })
|
time = await translate(ui.string.Months, { months: calculateMonthsPassed(now, value) })
|
||||||
} else {
|
} else {
|
||||||
time = await translate(ui.string.Years, { years: Math.floor(passed / YEAR) })
|
time = await translate(ui.string.Years, { years: Math.floor(passed / YEAR) })
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user