mirror of
https://shylinux.com/x/volcanos
synced 2025-04-26 09:14:06 +08:00
opt lunar.js
This commit is contained in:
parent
eefab21cd5
commit
8231ca15df
10
lib/lunar.js
10
lib/lunar.js
@ -19,19 +19,21 @@ var calendar = { /* @1900-2100区间内的公历转农历 */
|
||||
var gzY = this.toGanZhiYear(year)
|
||||
var gzM = this.toGanZhi((y-1900)*12+m+(d >= firstTerm? 12: 11))
|
||||
var gzD = this.toGanZhi(Date.UTC(y,m-1,1,0,0,0,0)/86400000+25567+10+d-1)
|
||||
|
||||
// 节日
|
||||
var nWeek = date.getDay(), cWeek = this.nStr3[nWeek]; if (nWeek == 0) { nWeek = 7 }
|
||||
function getFestival(list, m, d) { return list[m+"-"+d]? list[m+"-"+d].title: null }
|
||||
return {date: y+'-'+m+'-'+d,
|
||||
|
||||
var res = {date: y+'-'+m+'-'+d,
|
||||
Year: y, Month: m, Day: d,
|
||||
lunarDate: year+'-'+month+'-'+day,
|
||||
lYear: year, lMonth: month, lDay: day,
|
||||
gzYear: gzY, gzMonth: gzM, gzDay: gzD,
|
||||
Animal: this.getAnimal(year), IMonthCn: (isLeap?"\u95f0":'')+this.toChinaMonth(month), IDayCn: this.toChinaDay(day),
|
||||
Animal: this.getAnimal(year), cnMonth: (isLeap?"\u95f0":'')+this.toChinaMonth(month), cnDay: this.toChinaDay(day),
|
||||
isLeap: isLeap, isTerm: isTerm, Term: term, Astro: this.toAstro(m, d), nWeek: nWeek, ncWeek: "\u661f\u671f"+cWeek,
|
||||
lunarFestival: getFestival(this.lfestival, month, day), festival: getFestival(this.festival, m, d),
|
||||
}
|
||||
}; res.autoDay = res.lunarFestival||res.festival||term||(day==1? this.toChinaMonth(month): this.toChinaDay(day))
|
||||
res.autoClass = "lunar"+(res.lunarFestival||res.festival? " fest":"")+(res.isTerm? " term": "")
|
||||
return res
|
||||
},
|
||||
|
||||
/* 天干表 ["甲","乙","丙","丁","戊","己","庚","辛","壬","癸"] */
|
||||
|
@ -30,12 +30,10 @@ Volcanos(chat.ONFIGURE, {date: {
|
||||
|
||||
can.page.Appends(can, can._table, [{th: ["日", "一", "二", "三", "四", "五", "六"]}])
|
||||
var tr; function add(day, type) { if (day.getDay() == 0) { tr = can.page.Append(can, can._table, [{type: html.TR}]).last } var _day = new Date(day)
|
||||
var _lunar = lunar(day)
|
||||
var l = lunar(day)
|
||||
can.page.Append(can, tr, [{view: [can.base.isIn(can.base.Time(day, "%y-%m-%d"), can.base.Time(now, "%y-%m-%d"), can.base.Time(today, "%y-%m-%d"))? html.SELECT: type, html.TD],
|
||||
onclick: function(event) { _day.setHours(now.getHours()), _day.setMinutes(now.getMinutes()), _day.getSeconds(now.getSeconds()), _cb(_day), can.close() },
|
||||
list: [{text: day.getDate()+""}, {text: [_lunar.lunarFestival||_lunar.festival||_lunar.Term||(_lunar.IDayCn == "初一"? _lunar.IMonthCn: _lunar.IDayCn)],
|
||||
"className": "lunar"+(_lunar.lunarFestival||_lunar.festival? " fest":"")+(_lunar.isTerm? " term": "")},
|
||||
]}])
|
||||
onclick: function(event) { _day.setHours(now.getHours()), _day.setMinutes(now.getMinutes()), _day.getSeconds(now.getSeconds()), _cb(_day), meta._hold? show(_day): can.close() },
|
||||
list: [{text: day.getDate()+""}, {text: l.autoDay, "className": l.autoClass}]}])
|
||||
}
|
||||
|
||||
var one = new Date(now); one.setDate(1)
|
||||
@ -49,8 +47,7 @@ Volcanos(chat.ONFIGURE, {date: {
|
||||
var l = lunar(now); can.page.Appends(can, can._status, [{view: "today", inner: [l.gzYear, l.Animal+"年", l.Astro].join(ice.SP)}])
|
||||
return now
|
||||
}
|
||||
can.require(["/lib/lunar.js"], function() {
|
||||
lunar = function(year, month, day) { return calendar.solar2lunar(year,month,day) }
|
||||
can.require(["/lib/lunar.js"], function() { lunar = function(day) { return calendar.solar2lunar(day) }
|
||||
show(now), can._show = function(d) { _cb(show(new Date(now.getTime()+d*24*3600*1000))) }
|
||||
})
|
||||
})},
|
||||
|
@ -3,7 +3,7 @@ Volcanos(chat.ONIMPORT, {help: "导入数据",
|
||||
can.ui._tabs = can.page.insertBefore(can, ["tabs"], can.ui._content), can.ui._path = can.page.insertBefore(can, ["path"], can.ui._content)
|
||||
can.page.Append(can, can.ui._tabs, [{view: [["time", "select"]], style: {"float": html.RIGHT}, _init: function(target) {
|
||||
can.core.Timer({interval: 100}, function() { can.page.Appends(can, target, [{text: can.base.Time()}]) })
|
||||
can.onappend.figure(can, {action: "date"}, target, function(sub, value) { can.onimport.tabview(can, can.Option(nfs.PATH), "web.team.plan", ctx.INDEX) })
|
||||
can.onappend.figure(can, {action: "date", _hold: true}, target, function(sub, value) { can.onimport.tabview(can, can.Option(nfs.PATH), "web.team.plan", ctx.INDEX) })
|
||||
target.onmouseenter = target.click
|
||||
}}])
|
||||
},
|
||||
|
@ -5,6 +5,9 @@ fieldset.plan>div.output table.content.plan td.over { border:solid 2px red; }
|
||||
fieldset.plan>div.output table.content.plan td.today { background-color:cornflowerblue; }
|
||||
fieldset.plan>div.output table.content.plan td div { color:white; }
|
||||
fieldset.plan>div.output table.content.plan td div.date { color:gray; }
|
||||
fieldset.plan>div.output table.content.plan td div.date span.lunar { font-size:12px; }
|
||||
fieldset.plan>div.output table.content.plan td div.date span.lunar.fest { color:red; }
|
||||
fieldset.plan>div.output table.content.plan td div.date span.lunar.term { color:green; }
|
||||
fieldset.plan>div.output table.content.plan td div.prepare { background-color:blue; }
|
||||
fieldset.plan>div.output table.content.plan td div.process { background-color:green; }
|
||||
fieldset.plan>div.output table.content.plan td div.cancel { background-color:red; }
|
||||
|
@ -82,7 +82,8 @@ Volcanos(chat.ONIMPORT, {_init: function(can, msg, target) { can.onmotion.clear(
|
||||
var begin = can.base.TimeAdd(begin_time, -(begin_time.getDate()-1))
|
||||
var last = can.base.TimeAdd(begin_time, -(begin_time.getDate()-1)-begin.getDay())
|
||||
var day = can.base.TimeAdd(last, (row-1)*7+col)
|
||||
return [day.getDate()+""].concat(hash[key(day)]||[])
|
||||
var l = calendar.solar2lunar(day)
|
||||
return [can.page.Format(html.SPAN, day.getDate(), "day")+" "+can.page.Format(html.SPAN, l.autoDay, l.autoClass)].concat(hash[key(day)]||[])
|
||||
}
|
||||
function set(begin_time, col, row) {
|
||||
var begin = can.base.TimeAdd(begin_time, -(begin_time.getDate()-1))
|
||||
|
Loading…
x
Reference in New Issue
Block a user