Mercurial > hg
comparison mercurial/formatter.py @ 37770:31750413f8d7
formatter: convert timestamp to int
Spotted while porting jsonchangeset printer to formatter. A timestamp may be
float type, but its meaningful part is just int.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Fri, 13 Apr 2018 22:58:49 +0900 |
parents | d110167610db |
children | 395571419274 |
comparison
equal
deleted
inserted
replaced
37769:6a7ff5816c5f | 37770:31750413f8d7 |
---|---|
142 '''wrap nested data by appropriate type''' | 142 '''wrap nested data by appropriate type''' |
143 return data | 143 return data |
144 @staticmethod | 144 @staticmethod |
145 def formatdate(date, fmt): | 145 def formatdate(date, fmt): |
146 '''convert date tuple to appropriate format''' | 146 '''convert date tuple to appropriate format''' |
147 return date | 147 # timestamp can be float, but the canonical form should be int |
148 ts, tz = date | |
149 return (int(ts), tz) | |
148 @staticmethod | 150 @staticmethod |
149 def formatdict(data, key, value, fmt, sep): | 151 def formatdict(data, key, value, fmt, sep): |
150 '''convert dict or key-value pairs to appropriate dict format''' | 152 '''convert dict or key-value pairs to appropriate dict format''' |
151 # use plain dict instead of util.sortdict so that data can be | 153 # use plain dict instead of util.sortdict so that data can be |
152 # serialized as a builtin dict in pickle output | 154 # serialized as a builtin dict in pickle output |