on master help sign in
Fixed timezone issue
133cebaDevine Lu Linvega
scripts/hallway.js+4−7
@@ -36,7 +36,7 @@ function Hallway (sites) {
36 a.push(entry)
36 a.push(entry)
37 }
37 }
38 }
38 }
39− return a.sort(compare).reverse()
39+ return a.sort(compare)
40 }
40 }
41
41
42 this.templateEntry = function (entry) {
42 this.templateEntry = function (entry) {
@@ -89,7 +89,7 @@ function Hallway (sites) {
89 // Utils
89 // Utils
90
90
91 function compare (a, b) {
91 function compare (a, b) {
92− return a.date < b.date ? -1 : a.date > b.date ? 1 : 0
92+ return a.offset < b.offset ? -1 : a.offset > b.offset ? 1 : 0
93 }
93 }
94
94
95 function parseFeed (author, feed) {
95 function parseFeed (author, feed) {
@@ -101,16 +101,13 @@ function Hallway (sites) {
101 const parts = line.replace(' ', '\t').split('\t')
101 const parts = line.replace(' ', '\t').split('\t')
102 const date = parts[0].trim()
102 const date = parts[0].trim()
103 const body = parts[1].trim()
103 const body = parts[1].trim()
104+ const offset = new Date() - new Date(date)
104− entries.push({ date, body, author })
105+ entries.push({ date, body, author, offset })
105 }
106 }
106 return entries
107 return entries
107 }
108 }
108
109
109 function timeAgo (dateParam) {
110 function timeAgo (dateParam) {
110− if (!dateParam) {
111− return null
112− }
113−
114 const date = typeof dateParam === 'object' ? dateParam : new Date(dateParam)
111 const date = typeof dateParam === 'object' ? dateParam : new Date(dateParam)
115 const DAY_IN_MS = 86400000 // 24 * 60 * 60 * 1000
112 const DAY_IN_MS = 86400000 // 24 * 60 * 60 * 1000
116 const today = new Date()
113 const today = new Date()