From 9e22023a1252be2e34a3e509e7feb2ff6215fd37 Mon Sep 17 00:00:00 2001
From: yujian <yujian@123.com>
Date: 星期四, 30 五月 2019 10:42:36 +0800
Subject: [PATCH] 时间修正

---
 fanli/src/main/java/com/yeshi/fanli/controller/client/v1/DynamicController.java |   36 +++++++++++++++++++++++++-----------
 1 files changed, 25 insertions(+), 11 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/DynamicController.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/DynamicController.java
index 790350b..9c026b0 100644
--- a/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/DynamicController.java
+++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/DynamicController.java
@@ -199,19 +199,33 @@
 					
 					long old = value.getTime();
 					long now = nowDate.getTime();
-					if (y1 == y2 && d1 == d2) {//鍒ゆ柇鏄笉鏄悓涓�骞寸殑鍚屼竴澶�
-						long cha = now - old;
-						if (cha < 1000 * 60 * 2L)
-							desc = "鍒氬垰";
-						else if (cha < 1000 * 60 * 60L)
-							desc = (cha / (1000 * 60)) + "鍒嗛挓鍓�";
-						else
-							desc = (cha / (1000 * 60 * 60)) + "灏忔椂鍓�";
-					} else if (d2 - d1 == 1) {
-						desc = "鏄ㄥぉ";
+					if (y1 == y2) {
+						if (d1 == d2) {
+							long cha = now - old;
+							if (cha < 1000 * 60 * 2L) {
+								desc = "鍒氬垰";
+							}else if (cha < 1000 * 60 * 60L) {
+								desc = (cha / (1000 * 60)) + "鍒嗛挓鍓�";
+							}else {
+								desc = (cha / (1000 * 60 * 60)) + "灏忔椂鍓�";
+							}
+						} else if (d2 - d1 == 1) {
+							desc = "鏄ㄥぉ";
+						} else {
+							desc = (d2 - d1) + "澶╁墠";
+						}
 					} else {
-						desc = (d2 - d1) + "澶╁墠";
+						int timeDistance = 0;
+						for (int i = y1; i < y2; i++) {
+							if (i % 4 == 0 && i % 100 != 0 || i % 400 == 0) {
+								timeDistance += 366; // 闂板勾
+							} else {
+								timeDistance += 365; // 涓嶆槸闂板勾
+							}
+						}
+						desc = timeDistance + (d2 - d1) + "澶╁墠";
 					}
+
 					return new JsonPrimitive(desc);
 				}
 

--
Gitblit v1.8.0