Skip to content

Commit

Permalink
main
Browse files Browse the repository at this point in the history
  • Loading branch information
tuyangJs committed Dec 24, 2024
1 parent 86d0c8e commit 37cdeb9
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 0 deletions.
Empty file added README.md
Empty file.
24 changes: 24 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
function 获取当前时辰(format, currentTime) {
format = format ? format : "地支(时辰)时刻"
currentTime = currentTime ? currentTime : new Date

// 获取小时和分钟
const hours = currentTime.getHours();
let minutes = currentTime.getMinutes();

const 十二地支 = ["子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥"]
const 十二辰时 = ["夜半", "鸡鸣", "平旦", "日出", "食时", "隅中", "日平", "日昳", "晡时", "日入", "黄昏", "人定"]
const CNint = ['一', '二', '三', '四', '五', '六', '七', '八']
const i = TimeIndex(hours)
minutes = (TimeIndex(hours - 1) === i) ? (60 + minutes) : minutes //计算是否延长分钟大于60
const = Math.floor(minutes / 15) // 每时辰划分为8刻

format = format.replace("地支", 十二地支[i] + '时')
format = format.replace("时辰", 十二辰时[i])
format = format.replace("时刻", CNint[] + '刻')
function TimeIndex(h) {
return Math.floor((h + 1) / 2 )
}
return format
}
console.log(获取当前时辰())
Empty file added main/index.js
Empty file.
14 changes: 14 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "zodiac_time",
"version": "1.0.0",
"main": "index.js",
"module": "main/index.js",
"private": false,
"type": "module",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"description": ""
}
Binary file added s.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 37cdeb9

Please sign in to comment.