Skip to content

Instantly share code, notes, and snippets.

@sylhare
Created June 22, 2020 15:18
Show Gist options
  • Save sylhare/dad7ed1ef3d13614c77c4ebadf8a11c3 to your computer and use it in GitHub Desktop.
Save sylhare/dad7ed1ef3d13614c77c4ebadf8a11c3 to your computer and use it in GitHub Desktop.

Revisions

  1. sylhare created this gist Jun 22, 2020.
    17 changes: 17 additions & 0 deletions example.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    #!/usr/bin/env python3
    """ https://wiki.python.org/moin/SimplePrograms """
    from time import localtime

    activities = {8: 'Sleeping', 9: 'Commuting',
    17: 'Working', 18: 'Commuting',
    20: 'Eating', 22: 'Resting' }

    time_now = localtime()
    hour = time_now.tm_hour

    for activity_time in sorted(activities.keys()):
    if hour < activity_time:
    print (activities[activity_time])
    break
    else:
    print ('Unknown, AFK or sleeping!')