Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
open-webui
Commits
a341cfe3
Commit
a341cfe3
authored
May 04, 2024
by
Timothy J. Baek
Browse files
refac: getTimeRange
parent
36d8442c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
3 deletions
+11
-3
src/lib/utils/index.ts
src/lib/utils/index.ts
+11
-3
No files found.
src/lib/utils/index.ts
View file @
a341cfe3
...
...
@@ -529,15 +529,23 @@ export const getTimeRange = (timestamp) => {
const
diffTime
=
now
.
getTime
()
-
date
.
getTime
();
const
diffDays
=
diffTime
/
(
1000
*
3600
*
24
);
if
(
diffDays
<
1
)
{
const
nowDate
=
now
.
getDate
();
const
nowMonth
=
now
.
getMonth
();
const
nowYear
=
now
.
getFullYear
();
const
dateDate
=
date
.
getDate
();
const
dateMonth
=
date
.
getMonth
();
const
dateYear
=
date
.
getFullYear
();
if
(
nowYear
===
dateYear
&&
nowMonth
===
dateMonth
&&
nowDate
===
dateDate
)
{
return
'
Today
'
;
}
else
if
(
diffDays
<
2
)
{
}
else
if
(
nowYear
===
dateYear
&&
nowMonth
===
dateMonth
&&
nowDate
-
dateDate
===
1
)
{
return
'
Yesterday
'
;
}
else
if
(
diffDays
<=
7
)
{
return
'
Previous 7 days
'
;
}
else
if
(
diffDays
<=
30
)
{
return
'
Previous 30 days
'
;
}
else
if
(
date
.
getFull
Year
()
===
now
.
getFull
Year
()
)
{
}
else
if
(
now
Year
===
date
Year
)
{
return
date
.
toLocaleString
(
'
default
'
,
{
month
:
'
long
'
});
}
else
{
return
date
.
getFullYear
().
toString
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment