12/25/2022 0 Comments Geektool desktopI haven’t had any need to display times, so I haven’t programmed it. If you’d rather see how tomorrow relates to the current time, or how yesterday relates to the current time, specify “tomorrow” or “yesterday” to the -day option on the command line. The timedelta class is used to create, basically, a time range to subtract from or add to a datetime and when you subtract one datetime from another datetime, the result is a timedelta of the difference. I would have liked to use datetimes, dates, and timedeltas, but dates and datetimes are very different classes there’s a datetime.date() method, for example, but no date.datetime(), and the datetime.today() method is really just datetime.now(). The script uses Python’s datetime and timedelta classes to make these checks. Otherwise, it just says how many days to or since the current date. And if it’s within the last or next twelve months, it does the same for the month name. If it’s within one week in either direction, it displays “next” or “last” and then the weekday name. If it’s yesterday or tomorrow, then it displays that. If the current time is today, the script displays “today”. I set the geeklet to refresh every 60 seconds to ensure that the relative clock is always correct. date = today - datetime.timedelta(days=1)Įlif (date.year = today.year and date.month != today.month) or (date.year = today.year-1 and date.month >= today.month):.date = today + datetime.timedelta(days=1).future20 = () + datetime.timedelta(minutes=20).parser.add_option('-d', '-day', type='choice', choices=days, default='today').parser = optparse.OptionParser('%prog').days = ('yesterday', 'today', 'tomorrow').
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |