]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
Fixed wrong Chinese meridiem time, based on pull request #1056
authorZeno Zeng <zenoes@qq.com>
Sat, 14 Sep 2013 13:38:07 +0000 (21:38 +0800)
committerZeno Zeng <zenoes@qq.com>
Sat, 14 Sep 2013 13:38:07 +0000 (21:38 +0800)
lang/zh-cn.js

index 2f686065c35db4ed4907cd86ba6cad7aac1ffd2d..bffadbad8180cb87f94e5a5f9abf76b977511d75 100644 (file)
@@ -1,6 +1,7 @@
 // moment.js language configuration
 // language : chinese
 // author : suupic : https://github.com/suupic
+// author : Zeno Zeng : https://github.com/zenozeng
 
 (function (factory) {
     if (typeof define === 'function' && define.amd) {
             llll : "YYYY年MMMD日ddddLT"
         },
         meridiem : function (hour, minute, isLower) {
-            if (hour < 6) {
+            var hm = hour*100 + minute;
+            if (hm < 600) {
                 return "凌晨";
-            } else if (hour < 9) {
+            } else if (hm < 900) {
                 return "早上";
-            } else if (hour < 11 && minute < 30) {
+            } else if (hm < 1130) {
                 return "上午";
-            } else if (hour < 13 && minute < 30) {
+            } else if (hm < 1230) {
                 return "中午";
-            } else if (hour < 18) {
+            } else if (hm < 1800) {
                 return "下午";
             } else {
                 return "晚上";
             }
         },
         calendar : {
-            sameDay : function() {
+            sameDay : function () {
                 return this.minutes() === 0 ? "[今天]Ah[点整]" : "[今天]T";
             },
-            nextDay : function() {
+            nextDay : function () {
                 return this.minutes() === 0 ? "[明天]Ah[点整]" : "[明天]T";
             },
-            lastDay : function() {
+            lastDay : function () {
                 return this.minutes() === 0 ? "[昨天]Ah[点整]" : "[昨天]T";
             },
-            nextWeek : function() {
+            nextWeek : function () {
                 var startOfWeek, prefix;
                 startOfWeek = moment().startOf('week');
-                prefix = this.unix() - startOfWeek.unix() > 7*24*3600 ? '[下]' : '[本]';
-                return this.minutes() === 0 ? prefix+"dddAh点整" : prefix+"dddAh点mm";
+                prefix = this.unix() - startOfWeek.unix() > 7 * 24 * 3600 ? '[下]' : '[本]';
+                return this.minutes() === 0 ? prefix + "dddAh点整" : prefix + "dddAh点mm";
             },
-            lastWeek : function() {
+            lastWeek : function () {
                 var startOfWeek, prefix;
                 startOfWeek = moment().startOf('week');
                 prefix = this.unix() < startOfWeek.unix()  ? '[上]' : '[本]';
-                return this.minutes() === 0 ? prefix+"dddAh点整" : prefix+"dddAh点mm";
+                return this.minutes() === 0 ? prefix + "dddAh点整" : prefix + "dddAh点mm";
             },
             sameElse : 'L'
         },
         ordinal : function (number, period) {
             switch (period) {
-                case "d" :
-                case "D" :
-                case "DDD" :
+            case "d":
+            case "D":
+            case "DDD":
                 return number + "日";
-                case "M" :
+            case "M":
                 return number + "月";
-                case "w" :
-                case "W" :
+            case "w":
+            case "W":
                 return number + "周";
-                default :
+            default:
                 return number;
             }
         },