Skip to content
This repository has been archived by the owner on Nov 15, 2018. It is now read-only.

Commit

Permalink
fix(filters): 时间差过滤时无需再次计算时区
Browse files Browse the repository at this point in the history
  • Loading branch information
mutoe committed Jul 24, 2018
1 parent 9ddbb5f commit 0469da3
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,8 @@ export const time2txt = str => {
export const timeOffset = new Date().getTimezoneOffset() * 60 * 1000;

export const time2tips = date => {
const time =
new Date(typeof date === "string" ? date.replace(/-/g, "/") : date) -
timeOffset;
typeof date === "string" && (date = date.replace(/-/g, "/"));
const time = new Date(date);
const offset = (new Date().getTime() - time) / 1000;
if (offset < 60) return "1分钟内";
if (offset < 3600) return `${~~(offset / 60)}分钟前`;
Expand Down

0 comments on commit 0469da3

Please sign in to comment.