Preserve original UTC timestamp
This commit is contained in:
		
							parent
							
								
									3dc85639f4
								
							
						
					
					
						commit
						77f03425ef
					
				| 
						 | 
					@ -96,10 +96,11 @@ proc getTweetTime*(tweet: Tweet): string =
 | 
				
			||||||
  tweet.time.format("h:mm tt' · 'MMM d', 'YYYY")
 | 
					  tweet.time.format("h:mm tt' · 'MMM d', 'YYYY")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
proc getShortTime*(tweet: Tweet): string =
 | 
					proc getShortTime*(tweet: Tweet): string =
 | 
				
			||||||
  let
 | 
					  let now = now()
 | 
				
			||||||
    now = now().utc
 | 
					  var then = tweet.time.local()
 | 
				
			||||||
    then = tweet.time.utc
 | 
					  then.utcOffset = 0
 | 
				
			||||||
    since = now - then
 | 
					
 | 
				
			||||||
 | 
					  let since = now - then
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if now.year != then.year:
 | 
					  if now.year != then.year:
 | 
				
			||||||
    result = tweet.time.format("d MMM yyyy")
 | 
					    result = tweet.time.format("d MMM yyyy")
 | 
				
			||||||
| 
						 | 
					@ -112,7 +113,6 @@ proc getShortTime*(tweet: Tweet): string =
 | 
				
			||||||
  elif since.inSeconds > 1:
 | 
					  elif since.inSeconds > 1:
 | 
				
			||||||
    result = $since.inSeconds & "s"
 | 
					    result = $since.inSeconds & "s"
 | 
				
			||||||
  else:
 | 
					  else:
 | 
				
			||||||
    # this shouldn't happen, but just in case
 | 
					 | 
				
			||||||
    result = "now"
 | 
					    result = "now"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
proc getLink*(tweet: Tweet; focus=true): string =
 | 
					proc getLink*(tweet: Tweet; focus=true): string =
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -36,7 +36,7 @@ template getError*(js: JsonNode): Error =
 | 
				
			||||||
 | 
					
 | 
				
			||||||
template parseTime(time: string; f: static string; flen: int): Time =
 | 
					template parseTime(time: string; f: static string; flen: int): Time =
 | 
				
			||||||
  if time.len != flen: return
 | 
					  if time.len != flen: return
 | 
				
			||||||
  parseTime(time, f, utc())
 | 
					  parse(time, f).toTime
 | 
				
			||||||
 | 
					
 | 
				
			||||||
proc getDateTime*(js: JsonNode): Time =
 | 
					proc getDateTime*(js: JsonNode): Time =
 | 
				
			||||||
  parseTime(js.getStr, "yyyy-MM-dd\'T\'HH:mm:ss\'Z\'", 20)
 | 
					  parseTime(js.getStr, "yyyy-MM-dd\'T\'HH:mm:ss\'Z\'", 20)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue