Skip to content

Commit

Permalink
Fix bug with single digit months in now/nodate datestamp converters
Browse files Browse the repository at this point in the history
  • Loading branch information
dogoncouch committed Apr 5, 2018
1 parent 13896a3 commit 9d1c80e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Change log
Change log for [logdissect](https://github.com/dogoncouch/logdissect)

## [Unreleased]
### Fixed
- Bug with single-digit months in `now`/`nodate` datestamp converters

## [3.1] 2018-04-05
### Added
- `post_parse_action` parser method for more customization
Expand Down
6 changes: 3 additions & 3 deletions logdissect/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def convert_nodate_datestamp(entry, datedata):
else:
datedata['entry_time'] = int(entry['tstamp'])
entry['year'] = str(datedata['timestamp'].year)
entry['month'] = str(datedata['timestamp'].month)
entry['month'] = str(datedata['timestamp'].month.rjust(2, '0'))
entry['day'] = str(datedata['timestamp'].day).rjust(2, '0')
entry['numeric_date_stamp'] = entry['year'] + entry['month'] + \
entry['day'] + entry['tstamp']
Expand Down Expand Up @@ -133,8 +133,8 @@ def convert_now_datestamp(entry):
timestamp = datetime.now()
entry['date_stamp'] = timestamp.strftime('%Y %b %d %H:%M:%S.%f')
entry['year'] = str(timestamp.year)
entry['month'] = str(timestamp.month)
entry['day'] = str(timestamp.day)
entry['month'] = str(timestamp.month).rjust(2, '0')
entry['day'] = str(timestamp.day).rjust(2, '0')
entry['tstamp'] = timestamp.strftime('%H%M%S.%f')
entry['numeric_date_stamp'] = entry['year'] + entry['month'] + \
entry['day'] + entry['tstamp']
Expand Down

0 comments on commit 9d1c80e

Please sign in to comment.