Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
giovannicoppola committed Nov 28, 2022
2 parents 6b6db92 + f730ad2 commit 97f0fcf
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 20 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Date Calculator
Hello there!
I needed a bit of motivation to learn Python and Alfred workflows, so I thought I’d kill two horses with one bullet, so to speak.
Right, so this is a date calculator – kind of. It won’t tell you when you will the lottery, or how long you’ve got to hide your ‘arty videos’ before your wife gets home, but it will answer one or two _very simple_ questions about dates.

Original by [@MuppetGate](https://github.com/MuppetGate)


![](http://www.packal.org/sites/default/files/public/workflow-files/muppetgatenetdatecalculator/screenshots/screenshot2014-06-21at084104.png)

Expand Down
Binary file added images/Screenshot 2022-11-28 at 7.10.41 AM.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified releases/DateCalculator_4-0-1.alfredworkflow
Binary file not shown.
Binary file removed releases/DateCalculator_4-0-1b.alfredworkflow
Binary file not shown.
21 changes: 4 additions & 17 deletions src/date_calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@
from workflow import Workflow, ICON_ERROR


def log(s, *args):
if args:
s = s % args
print(s, file=sys.stderr)

class FormatError(Exception):
"""
Throw this when there are
Expand Down Expand Up @@ -98,18 +93,12 @@ def delta_arithmetic(date_time, operand):
def do_timespans(command, settings):
date_time, output_format = convert_date_time(command.dateTime, settings)
original_date_time = date_time
#log ('========================ORIGINAL ==============')
#log (original_date_time)

for operand in command.operandList:
date_time = delta_arithmetic(date_time, operand)

date_time = exclusion_check(original_date_time, date_time, command, settings)
#log ('========================DATE TIME OUTPUT ==============')
#log (date_time)
#log ('========================OUTPUT FORMAT ==============')
#log (output_format)
if settings['date-format'] == 'd.m.yyyy':
output_format = '%-d.%-m.%Y'

return date_time.strftime(output_format)


Expand Down Expand Up @@ -352,12 +341,10 @@ def main(wf):
try:

command = command_parser.parse_command(args[0])
#log ('========================TESTING ==============')
#log ("////////--" + command.dateTime + "--//////////")

if hasattr(command, "dateTime"):
#log ('========================HAS DATE ==============')
output = do_timespans(command, wf.settings)
#log ("////////--" + output + "--//////////")

if hasattr(command, "dateFormat"):
setattr(command, "dateTime", output)
# and run it through the functions function
Expand Down
3 changes: 3 additions & 0 deletions src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,14 @@ def convert_date_time(date_time, settings):
date_format = get_date_format(settings)
time_format = get_time_format(settings)
full_format = get_full_format(settings)
<<<<<<< Updated upstream
log ('========================DATE FORMAT ==============')
log (date_format)
log ('========================FULL FORMAT ==============')

log (full_format)
=======
>>>>>>> Stashed changes
if date_format == '%-d.%-m.%Y':
date_format = '%d.%m.%Y'

Expand Down

0 comments on commit 97f0fcf

Please sign in to comment.