CLI: move format_time to common + add timezone
This commit is contained in:
parent
d2ae4a124a
commit
44a54978b9
2 changed files with 14 additions and 14 deletions
|
|
@ -22,7 +22,6 @@ import json
|
|||
import sys
|
||||
import os.path
|
||||
import os
|
||||
import time
|
||||
import tempfile
|
||||
import subprocess
|
||||
import asyncio
|
||||
|
|
@ -290,10 +289,10 @@ class Get(base.CommandBase):
|
|||
return ", ".join(tags)
|
||||
|
||||
def format_updated(self, item, keys):
|
||||
return self.format_time(item["updated"])
|
||||
return common.format_time(item["updated"])
|
||||
|
||||
def format_published(self, item, keys):
|
||||
return self.format_time(item["published"])
|
||||
return common.format_time(item["published"])
|
||||
|
||||
def format_url(self, item, keys):
|
||||
return uri.buildXMPPUri(
|
||||
|
|
@ -372,15 +371,6 @@ class Get(base.CommandBase):
|
|||
if idx < len(items) - 1:
|
||||
print("")
|
||||
|
||||
def format_time(self, timestamp):
|
||||
"""return formatted date for timestamp
|
||||
|
||||
@param timestamp(str,int,float): unix timestamp
|
||||
@return (unicode): formatted date
|
||||
"""
|
||||
fmt = "%d/%m/%Y %H:%M:%S"
|
||||
return time.strftime(fmt, time.localtime(float(timestamp)))
|
||||
|
||||
def fancy_output(self, data):
|
||||
"""display blog is a nice to read way
|
||||
|
||||
|
|
@ -413,10 +403,10 @@ class Get(base.CommandBase):
|
|||
if author:
|
||||
meta.append(A.color(A.FG_YELLOW, author))
|
||||
if published:
|
||||
meta.append(A.color(A.FG_YELLOW, "on ", self.format_time(published)))
|
||||
meta.append(A.color(A.FG_YELLOW, "on ", common.format_time(published)))
|
||||
if updated != published:
|
||||
meta.append(
|
||||
A.color(A.FG_YELLOW, "(updated on ", self.format_time(updated), ")")
|
||||
A.color(A.FG_YELLOW, "(updated on ", common.format_time(updated), ")")
|
||||
)
|
||||
print((" ".join(meta)))
|
||||
if tags:
|
||||
|
|
|
|||
|
|
@ -52,6 +52,16 @@ SECURE_UNLINK_DIR = ".backup"
|
|||
METADATA_SUFF = "_metadata.json"
|
||||
|
||||
|
||||
def format_time(timestamp):
|
||||
"""Return formatted date for timestamp
|
||||
|
||||
@param timestamp(str,int,float): unix timestamp
|
||||
@return (unicode): formatted date
|
||||
"""
|
||||
fmt = "%d/%m/%Y %H:%M:%S %Z"
|
||||
return time.strftime(fmt, time.localtime(float(timestamp)))
|
||||
|
||||
|
||||
def ansi_ljust(s, width):
|
||||
"""ljust method handling ANSI escape codes"""
|
||||
cleaned = regex.ansiRemove(s)
|
||||
|
|
|
|||
Loading…
Reference in a new issue