diff --git a/_mobile/date.i18n.cn.js b/_mobile/date.i18n.cn.js deleted file mode 100644 index 79e294934..000000000 --- a/_mobile/date.i18n.cn.js +++ /dev/null @@ -1,67 +0,0 @@ -/** - * Created by astronaut007 on 2018/8/8 - */ -// 牵扯到国际化这些常量在页面加载后再生效 -// full day names -BI.Date = BI.Date || {}; -BI.Date._DN = ["星期日", - "星期一", - "星期二", - "星期三", - "星期四", - "星期五", - "星期六", - "星期日"]; - -// short day names -BI.Date._SDN = ["日", - "一", - "二", - "三", - "四", - "五", - "六", - "日"]; - -// Monday first, etc. -BI.Date._FD = 1; - -// full month namesdat -BI.Date._MN = [ - "一月", - "二月", - "三月", - "四月", - "五月", - "六月", - "七月", - "八月", - "九月", - "十月", - "十一月", - "十二月"]; - -// short month names -BI.Date._SMN = [0, - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11]; - -BI.Date._QN = ["", "第1季度", - "第2季度", - "第3季度", - "第4季度"]; - -/** Adds the number of days array to the Date object. */ -BI.Date._MD = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; - -// 实际上无论周几作为一周的第一天,周初周末都是在-6-0间做偏移,用一个数组就可以 -BI.Date._OFFSET = [0, -1, -2, -3, -4, -5, -6]; diff --git a/src/case/calendar/calendar.js b/src/case/calendar/calendar.js index f5a99e37d..5c5026d8f 100644 --- a/src/case/calendar/calendar.js +++ b/src/case/calendar/calendar.js @@ -120,7 +120,7 @@ BI.Calendar = BI.inherit(BI.Widget, { _getWeekLabel: function () { return BI.map(BI.range(0, 7), function (idx, v) { - return BI.Date._SDN[(v + BI.StartOfWeek) % 7]; + return BI.getShortDayName((v + BI.StartOfWeek) % 7); }); }, diff --git a/src/core/constant/date.i18n.js b/src/core/constant/date.i18n.js deleted file mode 100644 index 67f8c93d0..000000000 --- a/src/core/constant/date.i18n.js +++ /dev/null @@ -1,66 +0,0 @@ -BI.prepares.push(function () { - BI.Date = BI.Date || {}; - // 牵扯到国际化这些常量在页面加载后再生效 - // full day names - BI.Date._DN = [BI.i18nText("BI-Basic_Sunday"), - BI.i18nText("BI-Basic_Monday"), - BI.i18nText("BI-Basic_Tuesday"), - BI.i18nText("BI-Basic_Wednesday"), - BI.i18nText("BI-Basic_Thursday"), - BI.i18nText("BI-Basic_Friday"), - BI.i18nText("BI-Basic_Saturday"), - BI.i18nText("BI-Basic_Sunday")]; - - // short day names - BI.Date._SDN = [BI.i18nText("BI-Basic_Simple_Sunday"), - BI.i18nText("BI-Basic_Simple_Monday"), - BI.i18nText("BI-Basic_Simple_Tuesday"), - BI.i18nText("BI-Basic_Simple_Wednesday"), - BI.i18nText("BI-Basic_Simple_Thursday"), - BI.i18nText("BI-Basic_Simple_Friday"), - BI.i18nText("BI-Basic_Simple_Saturday"), - BI.i18nText("BI-Basic_Simple_Sunday")]; - - // Monday first, etc. - BI.Date._FD = 1; - - // full month namesdat - BI.Date._MN = [ - BI.i18nText("BI-Basic_January"), - BI.i18nText("BI-Basic_February"), - BI.i18nText("BI-Basic_March"), - BI.i18nText("BI-Basic_April"), - BI.i18nText("BI-Basic_May"), - BI.i18nText("BI-Basic_June"), - BI.i18nText("BI-Basic_July"), - BI.i18nText("BI-Basic_August"), - BI.i18nText("BI-Basic_September"), - BI.i18nText("BI-Basic_October"), - BI.i18nText("BI-Basic_November"), - BI.i18nText("BI-Basic_December")]; - - // short month names - BI.Date._SMN = [0, - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11]; - - BI.Date._QN = ["", BI.i18nText("BI-Quarter_1"), - BI.i18nText("BI-Quarter_2"), - BI.i18nText("BI-Quarter_3"), - BI.i18nText("BI-Quarter_4")]; - - /** Adds the number of days array to the Date object. */ - BI.Date._MD = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; - - // 实际上无论周几作为一周的第一天,周初周末都是在-6-0间做偏移,用一个数组就可以 - BI.Date._OFFSET = [0, -1, -2, -3, -4, -5, -6]; -}); \ No newline at end of file diff --git a/src/core/func/alias.js b/src/core/func/alias.js index e30d88c24..0dca26ca6 100644 --- a/src/core/func/alias.js +++ b/src/core/func/alias.js @@ -804,7 +804,7 @@ var str = jfmt.str, len = jfmt.len, ch = jfmt["char"]; switch (ch) { case "E": // 星期 - str = BI.Date._DN[date.getDay()]; + str = BI.getFullDayName(date.getDay()); break; case "y": // 年 if (len <= 3) { diff --git a/src/core/func/date.js b/src/core/func/date.js index 74bf3bea7..d603d235c 100644 --- a/src/core/func/date.js +++ b/src/core/func/date.js @@ -6,6 +6,29 @@ BI.Date.HOUR = 60 * BI.Date.MINUTE; BI.Date.DAY = 24 * BI.Date.HOUR; BI.Date.WEEK = 7 * BI.Date.DAY; +// Monday first, etc. +BI.Date._FD = 1; + +// short month names +BI.Date._SMN = [0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11]; + +/** Adds the number of days array to the Date object. */ +BI.Date._MD = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; + +// 实际上无论周几作为一周的第一天,周初周末都是在-6-0间做偏移,用一个数组就可以 +BI.Date._OFFSET = [0, -1, -2, -3, -4, -5, -6]; + BI._.extend(BI, { /** * 获取时区 @@ -136,6 +159,50 @@ BI._.extend(BI, { return BI.getOffsetDate(date, BI.Date._OFFSET[w < startOfWeek ? (7 + w - startOfWeek) : (w - startOfWeek)] + 6); }, + getFullDayName: function (index) { + return [BI.i18nText("BI-Basic_Sunday"), + BI.i18nText("BI-Basic_Monday"), + BI.i18nText("BI-Basic_Tuesday"), + BI.i18nText("BI-Basic_Wednesday"), + BI.i18nText("BI-Basic_Thursday"), + BI.i18nText("BI-Basic_Friday"), + BI.i18nText("BI-Basic_Saturday"), + BI.i18nText("BI-Basic_Sunday")][index]; + }, + + getShortDayName: function (index) { + return [BI.i18nText("BI-Basic_Simple_Sunday"), + BI.i18nText("BI-Basic_Simple_Monday"), + BI.i18nText("BI-Basic_Simple_Tuesday"), + BI.i18nText("BI-Basic_Simple_Wednesday"), + BI.i18nText("BI-Basic_Simple_Thursday"), + BI.i18nText("BI-Basic_Simple_Friday"), + BI.i18nText("BI-Basic_Simple_Saturday"), + BI.i18nText("BI-Basic_Simple_Sunday")][index]; + }, + + getMonthName: function (index) { + return [BI.i18nText("BI-Basic_January"), + BI.i18nText("BI-Basic_February"), + BI.i18nText("BI-Basic_March"), + BI.i18nText("BI-Basic_April"), + BI.i18nText("BI-Basic_May"), + BI.i18nText("BI-Basic_June"), + BI.i18nText("BI-Basic_July"), + BI.i18nText("BI-Basic_August"), + BI.i18nText("BI-Basic_September"), + BI.i18nText("BI-Basic_October"), + BI.i18nText("BI-Basic_November"), + BI.i18nText("BI-Basic_December")][index] + }, + + getQuarterName: function (index) { + return ["", BI.i18nText("BI-Quarter_1"), + BI.i18nText("BI-Quarter_2"), + BI.i18nText("BI-Quarter_3"), + BI.i18nText("BI-Quarter_4")][index]; + }, + // 格式化打印日期 print: function (date, str) { var m = date.getMonth(); @@ -158,10 +225,10 @@ BI._.extend(BI, { } var min = date.getMinutes(); var sec = date.getSeconds(); - s["%a"] = BI.Date._SDN[w]; // abbreviated weekday name [FIXME: I18N] - s["%A"] = BI.Date._DN[w]; // full weekday name + s["%a"] = BI.getShortDayName(w); // abbreviated weekday name [FIXME: I18N] + s["%A"] = BI.getFullDayName(w); // full weekday name s["%b"] = BI.Date._SMN[m]; // abbreviated month name [FIXME: I18N] - s["%B"] = BI.Date._MN[m]; // full month name + s["%B"] = BI.getMonthName(m); // full month name // FIXME: %c : preferred date and time representation for the current locale s["%C"] = 1 + Math.floor(y / 100); // the century number s["%d"] = (d < 10) ? ("0" + d) : d; // the day of the month (range 01 to 31) diff --git a/src/widget/yearquarter/card.static.yearquarter.js b/src/widget/yearquarter/card.static.yearquarter.js index 78cdb518c..cf54c6fcf 100644 --- a/src/widget/yearquarter/card.static.yearquarter.js +++ b/src/widget/yearquarter/card.static.yearquarter.js @@ -8,16 +8,16 @@ BI.StaticYearQuarterCard = BI.inherit(BI.Widget, { _createQuarter: function () { var self = this; var items = [{ - text: BI.Date._QN[1], + text: BI.getQuarterName(1), value: 1 }, { - text: BI.Date._QN[2], + text: BI.getQuarterName(2), value: 2 }, { - text: BI.Date._QN[3], + text: BI.getQuarterName(3), value: 3 }, { - text: BI.Date._QN[4], + text: BI.getQuarterName(4), value: 4 }]; return BI.map(items, function (j, item) {