统一补够6行

master
yutent 2023-08-20 00:39:11 +08:00
parent bc55309c1a
commit d91ed4e414
3 changed files with 11 additions and 7 deletions

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,7 @@
{ {
"name": "bash-calendar", "name": "bash-calendar",
"description": "终端版万年历", "description": "终端版万年历",
"version": "1.2.6", "version": "1.2.7",
"author": "yutent <yutent.io@gmail.com>", "author": "yutent <yutent.io@gmail.com>",
"bin": { "bin": {
"calendar": "index.js", "calendar": "index.js",

View File

@ -92,8 +92,9 @@ export function getCalendarTable(year, month) {
list.push(tmp) list.push(tmp)
} }
nd = list.length % 7 // nd = list.length % 7
nd = nd > 0 ? 7 - nd : 0 // nd = nd > 0 ? 7 - nd : 0
nd = 42 - list.length // 统一补够6行
// 修正年月日的数值, 以匹配节假日 // 修正年月日的数值, 以匹配节假日
if (nd > 0) { if (nd > 0) {
@ -140,7 +141,7 @@ function drawThead(year, month) {
function drawTbody(year, month) { function drawTbody(year, month) {
var table = getCalendarTable(year, month) var table = getCalendarTable(year, month)
var line = 0 var line = 0
var maxi = 3 * Math.ceil(table.length / 7) var maxi = 3 * Math.ceil(table.length / 7) // 每个单元格占3行, 所以要 * 3
// i 是 纵坐标, j是横坐标格子 // i 是 纵坐标, j是横坐标格子
for (let i = 0; i < maxi + 1; i++) { for (let i = 0; i < maxi + 1; i++) {