This commit is contained in:
SelfRidicule 2024-03-04 15:49:05 +08:00
parent cba08d6f3f
commit 79d06953b0
2 changed files with 79 additions and 65 deletions

View File

@ -3,6 +3,8 @@ import {
meetingRoomBookedRecordRq
} from "../../../../api/meeting/meetingRoom.js"
import {selfFormatTimeReturnSecond59} from "../../../../utils/util.js"
Page({
/**
@ -30,8 +32,9 @@ Page({
// 选择-结束时间
onInputEndTime(event) {
let _this = this;
this.setData({
endTime: _this.addSeconds(event.detail , 59),
endTime: new Date(selfFormatTimeReturnSecond59(event.detail)).getTime(),
});
},
@ -81,10 +84,6 @@ Page({
})
},
// 添加指定秒数
addSeconds(time , seconds) {
return new Date(time.setSeconds(time.getSeconds() + seconds)).getTime();
},
/**
* 生命周期函数--监听页面加载

View File

@ -35,7 +35,7 @@ const formatDate = date => {
const second = date.getSeconds()
return [year, month, day].map(formatNumber).join('-')
}
//返回 例 2017--12-12 12:30:00
//返回 例 2017-12-12 12:30:00
const formatTime = date => {
const year = date.getFullYear()
const month = date.getMonth() + 1
@ -72,6 +72,20 @@ const formatHour = data => {
}
}
//返回 指定秒数59 2017-12-12 12:30:59
function selfFormatTimeReturnSecond59(time) {
let date = new Date(time);
let year = date.getFullYear()
let month = date.getMonth() + 1
let day = date.getDate()
let hour = date.getHours()
let minute = date.getMinutes()
let second = date.getSeconds()
return [year, month, day].map(formatNumber).join('-') + ' ' + [hour, minute, '59'].map(formatNumber).join(':')
}
const formatNumber = n => {
n = n.toString()
return n[1] ? n : '0' + n
@ -83,5 +97,6 @@ module.exports = {
formatYear: formatYear,
formatDate2: formatDate2,
formatHour: formatHour,
formatTime2: formatTime2
formatTime2: formatTime2,
selfFormatTimeReturnSecond59
}