miso-bot icon indicating copy to clipboard operation
miso-bot copied to clipboard

allow colon notation [HH:mm:ss] for remindme command [enhancement]

Open timpunny opened this issue 2 months ago • 0 comments

image

Proposed solution in util.py:

def timefromstring(s):
    """
    :param s : String to parse time from
    :returns : Time in seconds
    """
    s = s.removeprefix("for")
    
    # reduce colon notation to hms notation
    if ':' in s:
        # if only one colon, assume Xm:Xs
        if s.count(':') == 1:
            s = f"0:{s}"
        s = s.replace(":", "h", 1).replace(":", "m", 1) + "s"
        
    return int(Duration(s).to_seconds())

I don't have write access so I can't create the edit myself, nor can I add the "enhancement" tag to this post, apparently. (This is my first time posting an issue on a repo I don't own so this is a bit confusing for me.)

timpunny avatar Jun 12 '24 02:06 timpunny