Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed -d and -t flags #99

Merged
merged 4 commits into from
Sep 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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