python-xkcd icon indicating copy to clipboard operation
python-xkcd copied to clipboard

Comic Number and Comic Date

Open Kixiron opened this issue 7 years ago • 4 comments

Added two functions to the Comic class:

Get Date

getDate(dateType="MDY")

Returns the comic's date in one of three formats, defaulting to Month/Day/Year Possible formats:

  • Month/Year/Day MYD
  • Day/Month/Year DMY
  • Month/Day/Year MDY

More formats are easily added, I just chose the most used ones globally.

Edit: Now the date is returned as datetime

Get Comic Number

getNumber()

Pretty simple, returns the comic's number. Just a nice quality of life thing for people who use the API.

Further Changes:

Moved function definitions before class definitions, mostly to make my editor stop screaming at me.

Formatting

My formatting might be off, as I usually use spaces, but if there are any problems that I missed, they'll be easy enough to fix

Kixiron avatar Nov 30 '18 23:11 Kixiron

Thanks for the interest!

For getDate(), I think it would probably be better to return a datetime object (and then have the user decide how to format it)-- does that make sense to you? I think this module probably does not need its own list of date formats.

TC01 avatar Dec 01 '18 10:12 TC01

Thanks for the interest!

For getDate(), I think it would probably be better to return a datetime object (and then have the user decide how to format it)-- does that make sense to you? I think this module probably does not need its own list of date formats.

I converted it to datetime now, the only thing is that I had to import the datetime module

Kixiron avatar Dec 01 '18 13:12 Kixiron

Hi @Kixiron,

I believe these changes look okay. However, a few general stylistic comments.

  • It's usually better to break a pull request up instead of adding new, unrelated changes to an existing one (I prefer to work in branches for this reason, rather than working on the master branch of a fork). This is fine for now, but I'd ask you to avoid adding on more new changes for now.

  • It's unfortunate that you moved things around in the source file too. It makes it much harder to review what's actually been changed. Again, though, this is okay for now since the changes are pretty simple anyway.

  • It would be nice if you could squash commits together to make a cleaner git history; for example, things like this commit probably should be squashed into a neighboring commit. I can squash the entire branch manually when I merge ("squash and merge"), but then your master branch and my master branch won't agree. It it isn't too much trouble, it would be really nice if you could go through your commits with git rebase -i, combine some of them (especially the ones with very barebones commit messages), and then force push.

TC01 avatar Dec 03 '18 17:12 TC01

I'm really sorry, but I have no idea what to do with git bash, as I usually use the desktop app.

Kixiron avatar Dec 04 '18 00:12 Kixiron