comparison sat_frontends/jp/common.py @ 3667:9ca19b317293

CLI: move `format_time` to `common` + add timezone
author Goffi <goffi@goffi.org>
date Wed, 08 Sep 2021 17:58:48 +0200
parents 82e616b70a2a
children 742e466fa000
comparison
equal deleted inserted replaced
3666:342e3ddefd23 3667:9ca19b317293
48 } 48 }
49 49
50 SECURE_UNLINK_MAX = 10 50 SECURE_UNLINK_MAX = 10
51 SECURE_UNLINK_DIR = ".backup" 51 SECURE_UNLINK_DIR = ".backup"
52 METADATA_SUFF = "_metadata.json" 52 METADATA_SUFF = "_metadata.json"
53
54
55 def format_time(timestamp):
56 """Return formatted date for timestamp
57
58 @param timestamp(str,int,float): unix timestamp
59 @return (unicode): formatted date
60 """
61 fmt = "%d/%m/%Y %H:%M:%S %Z"
62 return time.strftime(fmt, time.localtime(float(timestamp)))
53 63
54 64
55 def ansi_ljust(s, width): 65 def ansi_ljust(s, width):
56 """ljust method handling ANSI escape codes""" 66 """ljust method handling ANSI escape codes"""
57 cleaned = regex.ansiRemove(s) 67 cleaned = regex.ansiRemove(s)