diff --git a/utils.js b/utils.js index f98385c..07b9fb4 100644 --- a/utils.js +++ b/utils.js @@ -78,6 +78,11 @@ function getDaySeconds(time, timeZone) { 3600 * timeZone; } +function getHourSeconds(time, timeZone) { + const daySeconds = getDaySeconds(time, timeZone); + return Math.floor((time - daySeconds) / 3600) * 3600; +} + function formatDate(date) { const year = date.getFullYear(); const month = date.getMonth() + 1;//月份是从0开始的 @@ -257,6 +262,7 @@ exports.isOnlineEnv = isOnlineEnv; exports.getTickCount = getTickCount; exports.getUtcTime = getUtcTime; exports.getDaySeconds = getDaySeconds; +exports.getHourSeconds = getHourSeconds; exports.formatDate = formatDate; exports.pad = pad; exports.randRange = randRange;