|
|
@@ -113,13 +113,13 @@ export class TimeFormatter {
|
|
|
}
|
|
|
|
|
|
//显示完整日期
|
|
|
- static timelineFullFormatTime(timestamp:number):string{
|
|
|
+ static timelineFullFormatTime(timestamp: number): string {
|
|
|
var date = new Date(timestamp)
|
|
|
var str = `${TimeFormatter.formatNumber(date.getHours())}:${TimeFormatter.formatNumber(date.getMinutes())}`;
|
|
|
- if (global.language=='en'){
|
|
|
- return `${TimeFormatter.getDayOfWeek(date.getDay())} ${TimeFormatter.getMonth(date.getMonth()+1)} ${date.getDate()} ${str}`
|
|
|
+ if (global.language == 'en') {
|
|
|
+ return `${TimeFormatter.getDayOfWeek(date.getDay())} ${TimeFormatter.getMonth(date.getMonth() + 1)} ${date.getDate()} ${str}`
|
|
|
}
|
|
|
- return `${TimeFormatter.getMonth(date.getMonth()+1)}${date.getDate()}日 ${TimeFormatter.getDayOfWeek(date.getDay())} ${str}`
|
|
|
+ return `${TimeFormatter.getMonth(date.getMonth() + 1)}${date.getDate()}日 ${TimeFormatter.getDayOfWeek(date.getDay())} ${str}`
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -219,7 +219,7 @@ export class TimeFormatter {
|
|
|
if (currentDate.getTime() - timestamp <= TimeFormatter.nowDuration * 1000) {
|
|
|
return TimeFormatter.dateDescription(timestamp, true)
|
|
|
}
|
|
|
- if (global.language=='en'){
|
|
|
+ if (global.language == 'en') {
|
|
|
return TimeFormatter.dateDescription(timestamp, true) + ' ' + TimeFormatter.timeDescription(timestamp)
|
|
|
}
|
|
|
return TimeFormatter.dateDescription(timestamp, true) + '' + TimeFormatter.timeDescription(timestamp)
|
|
|
@@ -475,34 +475,34 @@ export class TimeFormatter {
|
|
|
}
|
|
|
|
|
|
//获取时长单位
|
|
|
- static getSecondsUnit = (seconds,isFull?:boolean) =>{
|
|
|
- if (global.language=='en'){
|
|
|
- if (isFull){
|
|
|
- return seconds>1?' seconds ':' second '
|
|
|
+ static getSecondsUnit = (seconds, isFull?: boolean) => {
|
|
|
+ if (global.language == 'en') {
|
|
|
+ if (isFull) {
|
|
|
+ return seconds > 1 ? ' seconds ' : ' second '
|
|
|
}
|
|
|
- return seconds>1?' secs ':' sec '
|
|
|
+ return seconds > 1 ? ' secs ' : ' sec '
|
|
|
}
|
|
|
- return '秒'
|
|
|
+ return '秒'
|
|
|
}
|
|
|
|
|
|
- static getMinutesUnit = (minutes,isFull?:boolean) =>{
|
|
|
- if (global.language=='en'){
|
|
|
- if (isFull){
|
|
|
- return minutes>1?' minutes ':' minute '
|
|
|
+ static getMinutesUnit = (minutes, isFull?: boolean) => {
|
|
|
+ if (global.language == 'en') {
|
|
|
+ if (isFull) {
|
|
|
+ return minutes > 1 ? ' minutes ' : ' minute '
|
|
|
}
|
|
|
- return minutes>1?' mins ':' min '
|
|
|
+ return minutes > 1 ? ' mins ' : ' min '
|
|
|
}
|
|
|
- return '分钟'
|
|
|
+ return '分钟'
|
|
|
}
|
|
|
|
|
|
- static getHoursUnit = (hours,isFull?:boolean) =>{
|
|
|
- if (global.language=='en'){
|
|
|
- if (isFull){
|
|
|
- return hours>1?' hours ':' hour '
|
|
|
+ static getHoursUnit = (hours, isFull?: boolean) => {
|
|
|
+ if (global.language == 'en') {
|
|
|
+ if (isFull) {
|
|
|
+ return hours > 1 ? ' hours ' : ' hour '
|
|
|
}
|
|
|
- return hours>1?' hrs ':' hr '
|
|
|
+ return hours > 1 ? ' hrs ' : ' hr '
|
|
|
}
|
|
|
- return '小时'
|
|
|
+ return '小时'
|
|
|
}
|
|
|
|
|
|
static getTodayUnit = () => {
|
|
|
@@ -521,14 +521,14 @@ export class TimeFormatter {
|
|
|
return global.language == 'en' ? 'Just now' : '刚刚'
|
|
|
}
|
|
|
|
|
|
- static getDayOfWeek = (index,isFull?:boolean) => {
|
|
|
+ static getDayOfWeek = (index, isFull?: boolean) => {
|
|
|
var weeks = ['日', '一', '二', '三', '四', '五', '六']
|
|
|
var weeks2 = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'
|
|
|
];
|
|
|
- var weeksFull = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday']
|
|
|
+ var weeksFull = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
|
|
|
|
|
|
if (global.language == 'en') {
|
|
|
- if (isFull){
|
|
|
+ if (isFull) {
|
|
|
return weeksFull[index]
|
|
|
}
|
|
|
return weeks2[index]
|
|
|
@@ -548,4 +548,22 @@ export class TimeFormatter {
|
|
|
return index + '月'
|
|
|
}
|
|
|
|
|
|
+ //获取本周一零点的时间戳
|
|
|
+ static getMondayTimestamp = () => {
|
|
|
+ const now = new Date();
|
|
|
+ const currentDay = now.getDay(); // Get the current day of the week (0 for Sunday, 1 for Monday, etc.)
|
|
|
+ const startOfWeek = new Date(now); // Create a new Date object with the current date and time
|
|
|
+
|
|
|
+ // Calculate the difference in milliseconds to the beginning of the week
|
|
|
+ const diffToMonday = (currentDay - 1) * 24 * 60 * 60 * 1000; // Subtract 1 day worth of milliseconds for each day after Monday
|
|
|
+
|
|
|
+ startOfWeek.setTime(now.getTime() - diffToMonday); // Set the time to the beginning of the week (Monday at 00:00:00)
|
|
|
+ startOfWeek.setHours(0)
|
|
|
+ startOfWeek.setMinutes(0)
|
|
|
+ startOfWeek.setSeconds(0)
|
|
|
+ startOfWeek.setMilliseconds(0)
|
|
|
+ const timestamp = startOfWeek.getTime(); // Get the timestamp in milliseconds
|
|
|
+ return timestamp
|
|
|
+ }
|
|
|
+
|
|
|
}
|