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

remind: add support for dates in future #1162

Closed
wants to merge 2 commits into from

Conversation

alanhuang122
Copy link
Contributor

This pull request addresses issue #1148 by adding support for future dates, not just the next occurrence of the specified time.

@alanhuang122
Copy link
Contributor Author

I'm unsatisfied with the code quality upon review. If this functionality is desired, I can make a new PR.

@alanhuang122 alanhuang122 deleted the time-shenanigans branch January 5, 2018 05:04
@dgw
Copy link
Member

dgw commented Mar 29, 2018

@alanhuang122 BTW, this functionality is desired. See #1148, which I've left open.

@alanhuang122 alanhuang122 restored the time-shenanigans branch April 6, 2018 06:49
@alanhuang122 alanhuang122 reopened this Apr 6, 2018
@alanhuang122
Copy link
Contributor Author

alanhuang122 commented Apr 6, 2018

I'll work on this RSN.

@dgw
Copy link
Member

dgw commented Nov 5, 2018

@alanhuang122 Same question as I just asked in the other thread: Do you still intend to finish this, or should someone else adopt this PR?

@dgw dgw added this to the 6.6.0 milestone Nov 5, 2018
@alanhuang122
Copy link
Contributor Author

alanhuang122 commented Dec 7, 2018

Pushed a cleaned up version of the code, and force-pushed to appease Travis. Twice.

@alanhuang122 alanhuang122 force-pushed the time-shenanigans branch 2 times, most recently from 5ffaca7 to 987957a Compare December 7, 2018 02:37
sopel/modules/remind.py Outdated Show resolved Hide resolved
@dgw
Copy link
Member

dgw commented Dec 7, 2018

and force-pushed to appease Travis. Twice.

Story of my life 😹

I'll look at this & give it a good shakedown over the weekend, hopefully. Thanks for reviving it!

@dgw dgw assigned dgw and unassigned alanhuang122 Dec 7, 2018
Copy link
Member

@dgw dgw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Request: Rebase to put 6169b82 as fixup into 99c1278, or even squash both into 4153fa1 (but mostly I just want to be rid of the commit labeled copyediting 😁).

More importantly, I was hoping this would be all ready to merge now that I got a minute to review it, but… there's some timezone nonsense going on:

<dgw>   .at 12:00 2019-01-01 test reminder with date/time
<Sopel> dgw: Okay, will remind at 2019-01-01 - 18:00:00UTC
<dgw>   .at 12:00CST 2019-01-01 test reminder with date/time
<Sopel> dgw: Okay, will remind at 2019-01-01 - 18:00:00UTC
<dgw>   .at 12:00:00CST 2019-01-01 test reminder with date/time
<Sopel> dgw: Okay, will remind at 2019-01-01 - 18:00:00UTC
<dgw>   .at 12:34:00EST 2019-01-01 test reminder with date/time
<Sopel> dgw: Okay, will remind at 2019-01-01 - 13:34:00EST
<dgw>   .at 14:00EST 2019-01-01 test reminder with date/time
<Sopel> dgw: Okay, will remind at 2019-01-01 - 15:00:00EST
<dgw>   .at 14:00PST 2019-01-01 test reminder with date/time
<Sopel> dgw: Okay, will remind at 2019-01-01 - 20:00:00UTC
<dgw>   .at 14:00America/New_York 2019-01-01 test reminder with date/time
<Sopel> dgw: Okay, will remind at 2019-01-01 - 15:00:00EST

Sopel's default_timezone is UTC, but the system I'm testing on has its clock set to America/Chicago—though it is an Ubuntu system, so the internal clock should be UTC anyway, AFAIK.

When the displayed time is using UTC, it's correct. CST is UTC-0600, EST is UTC-0500, and PST is UTC-0800. Not sure what's up with the time-shifting though. Like, 14:00America/New_York shouldn't be translated to 15:00:00EST—it's 14:00:00EST.

It being past 3am, I'm too tired now to continue digging. But I'm hoping that, as the author of this patch, you'll have quicker insight than I, anyway, @alanhuang122 😉

@alanhuang122
Copy link
Contributor Author

Ack'd.
I do recall also finding some issue with timezones (probably the same) a few days ago, but haven't yet gotten around to porting the fix I (tried to?) make.

Alan Huang added 2 commits December 31, 2018 19:44
It's always better to do calculations in UTC.
Create a UTC "now", create a tz-aware "at" time,
then rely on pytz to handle the time difference across timezones.
@alanhuang122
Copy link
Contributor Author

Fixed and squashed (latest commit is preserved, for review).

@Exirel
Copy link
Contributor

Exirel commented Apr 21, 2019

It would be much easier to review this with confidence if it has unit-tests. For that, I suggest to extract everything until duration = timediff.seconds + 86400 * timediff.days into its own function. Something like:

def get_duration(trigger):
    regex = re.compile(...)
    # ... hard work ...
    return timediff.seconds + 86400 * timediff.days

And then:

def at(bot, trigger):
    # ... 

    try:
        duration = get_duration(trigger)
    except:
        bot.say('Error...')
        return

    if duration < 0:
        duration += 86400
        duration += 86400
    create_reminder(bot, trigger, duration, message, timezone)
    if timezone:
        create_reminder(bot, trigger, duration, message, timezone)
    else:
        create_reminder(bot, trigger, duration, message, 'UTC')

Of course, if you don't have time or interest in working on this PR again, I'll take for myself, so we don't lost all this hard work.

@Exirel Exirel added Replaced Superseded by a newer PR and removed Needs Review labels May 8, 2019
@Exirel Exirel removed the request for review from dgw May 8, 2019 10:49
@Exirel Exirel unassigned dgw May 8, 2019
@Exirel
Copy link
Contributor

Exirel commented May 8, 2019

I did the thing in #1590, closing here. Feel free to comment/review the new PR, help is still and always be welcome.

@Exirel Exirel closed this May 8, 2019
@dgw dgw removed this from the 7.0.0 milestone May 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Replaced Superseded by a newer PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants