Skip to content

Commit

Permalink
Merge pull request #99 from d-kleine/master
Browse files Browse the repository at this point in the history
fixed -d and -t flags
  • Loading branch information
rasbt authored Sep 22, 2024
2 parents dca8d30 + 1c06e02 commit eb56c6a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@ In line with [NEP 29][nep-29], this project supports:

[[top](#sections)]

#### v. 2.5.1.dev1 (TBD)

- Extra args to allow printing `-d` (current date) and `-t` (current time) information without needing to use the `-u` (updated) flag. ([#99](https://github.com/rasbt/watermark/pull/99), via contribution by [Daniel Kleine](https://github.com/d-kleine))

#### v. 2.5.0 (Sep 20, 2024)

- Can now capture imports retrospectively via `-iv` more reliably. ([#94](https://github.com/rasbt/watermark/pull/94), via contribution by [Martin Perier](https://github.com/martinp7))
Expand Down
18 changes: 14 additions & 4 deletions watermark/watermark.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,17 +172,27 @@ def watermark(
value = iso_dt
else:
values = []
if args['current_date']:
values.append(time.strftime("%Y-%m-%d"))
elif args['datename']:
values.append(time.strftime("%a %b %d %Y"))
if args['current_date'] or args['datename']:
if args['datename']:
values.append(time.strftime("%a %b %d %Y"))
else:
values.append(time.strftime("%Y-%m-%d"))
if args['current_time']:
time_str = time.strftime("%H:%M:%S")
if args['timezone']:
time_str += time.strftime("%Z")
values.append(time_str)
value = " ".join(values)
output.append({"Last updated": value})
elif args['current_date'] or args['current_time']:
if args['current_date'] and args['current_time']:
date_str = time.strftime("%Y-%m-%d")
time_str = time.strftime("%H:%M:%S")
output.append({"Date/Time": f"{date_str} {time_str}"})
elif args['current_date']:
output.append({"Date": time.strftime("%Y-%m-%d")})
elif args['current_time']:
output.append({"Time": time.strftime("%H:%M:%S")})
if args['python']:
output.append(_get_pyversions())
if args['packages']:
Expand Down

0 comments on commit eb56c6a

Please sign in to comment.