bbenefield89 / PythonAlarm

A CLI to set alarms
MIT License
2 stars 4 forks source link

Add ability to set alarm from command line #19

Open bbenefield89 opened 6 years ago

bbenefield89 commented 6 years ago

Expected Behavior

User can set time for alarm when starting Pylarm e.g. pylarm 2:37pm

Proposed Solution (if any)

Add new option in src/main.py to handle non-CLI options that would parse the time and set the alarm according to the 12hour format and meridiem given by the user.

justanotherlad commented 6 years ago

Hi ! I'm just beginning with open source contributions and I'd like to take this issue up! Can you please help me how to proceed with it? @bbenefield89

bbenefield89 commented 6 years ago

Hi, @swastikbanerjee07 thanks for taking an interest in Pylarm.

This particular issue needs updating. As of today, 10/10/2018, a pull-request has been merged into master solving what I believe to be the bulk of this, thanks to @ChatPion.

Do not fret, as this issue is not 100% complete. What you can do is add in the option to set a meridiem, e.g. A.M. or P.M.

Currently, one can use a command such as python <path to pylarm>/src/main.py 12:00 and Pylarm will decide whether or not this needs to be an A.M. or P.M. and choose the day for the user as well.

What I am suggesting to you is to now add that last bit of functionality so if a user were to supply a meridiem then there would be no need for Pylarm to make that decision for a user.

For example, if a user were to set an alarm for 12:00pm but it was actually 1:00pm, the alarm would be set for 12:00pm the following day. If user also set an alarm for 2:00pm and it was 1:00pm then the alarm would be set for one hour from that time.

Now, for some direction I would start playing around with the /src/main.py file and split the command line arguments up in a way that Python itself will know what to do with a pm or am when given a time.

There's already something very similar going on on line-32 I believe in the /src/main.py that is doing a lot of this. Perhaps that can guide you in adding further functionality.

Let me know if you have anymore questions and again thanks for taking an interest.

justanotherlad commented 6 years ago

Hi ! That's awesome! I'm looking into it!

justanotherlad commented 6 years ago

The previous code had various errors, like the set_alarm_manually file has a missing parameter as I have pointed out in an issue. However, I have debugged all the codes, and the new alarm now works cool and fine ! :)

The alarm now asks for a time in the beginning in 24Hrs format. If you give a time less than your current local time, it automatically tries to set the alarm in the next day ! And if you give a time which is yet to come today,i.e. more than your current time, then it sets the alarm for today. Before setting the final alarm, it asks for a confirmation. If you press Y , it sets the alarm. If you press N, it then asks you to set the alarm manually on your preferred month,date,year and time. :)

Hope I could make everything clear.

Please review and merge my Pull Request! Thanks.