zopefoundation / DateTime

This package provides a DateTime data type, as known from Zope. Unless you need to communicate with Zope APIs, you're probably better off using Python's built-in datetime module.
Other
19 stars 25 forks source link

supporting fstring formatting #35

Closed georgpfolz closed 2 years ago

georgpfolz commented 2 years ago

It would be great if DateTime could support the new fstring formatting like datetime already does:

import datetime, DateTime
for now in (datetime.datetime.now(), DateTime.DateTime()):
    try:
        print(type(now), f'{now = :%-d.%-m.%Y %H:%M}')
    except TypeError as e:
        print(type(now), e)

prints -->

<class 'datetime.datetime'> now = 26.5.2022 05:45
<class 'DateTime.DateTime.DateTime'> unsupported format string passed to DateTime.__format__
icemac commented 2 years ago

A PR is welcome.

georgpfolz commented 2 years ago

OK, I added the __format__ method in georgpfolz/DateTime. How do I do the pull request? My repository does not show in the repositories to compare with.

dataflake commented 2 years ago

@georgpfolz You have not signed the contributor agreement yet, right? At least I can't find you with "Member" status in the zopefoundation organization. If you have not signed it yet please do so (see https://www.zope.dev/developer/becoming-a-committer.html), otherwise we cannot accept substantial contributions from you.

georgpfolz commented 2 years ago

Ah, ok.

I'm nearly done filling it out, what am I supposed to write on page 2 in "Program"? "DateTime" or "Zope"?

Edit: I just found it in the explanation document. I'll use "Zope"

dataflake commented 2 years ago

Put down "Zope" - the agreement covers all zopefoundation organization repositories. Thanks!

georgpfolz commented 2 years ago

Ok, I'm now member of the zopefoundation, but I still cannot see my repository in the compare page. Or does it take some time to update?

d-maurer commented 2 years ago

Georg Pfolz wrote at 2022-6-25 15:00 -0700:

Ok, I'm now member of the zopefoundation, but I still cannot see my repository in the compare page. Or does it take some time to update?

A long time ago, I, too, tried to create a pull request between a privat fork and the base zopefoundation repository. I finally succeeded but it has not been easy. Then @dateflake suggested to work in the zopefoundation repository directly -- it facilitates cowork with the reviewers. This is open to you: extract a patch from your fork and apply it to a clone of the base repository; make a PR from this change.

georgpfolz commented 2 years ago

I'm not sure I understand how to do this exactly. As far as I understand, I would clone the repository and create a new branch which I would push back to the zopefoundation/DateTime repository and then initiate the pull request. Or I could create a branch online and clone it locally.

How can I push to the repository? Don't I need a deploy key to do it?

dataflake commented 2 years ago

git push? You do not need a deploy key, just your own GitHub credentials.

dataflake commented 2 years ago

Or to put it differently: You work with this repository exactly the same as you would with one of your own repositories. Your GitHub user is put into the "Member" group here when you sign the contributor agreement, which gives you the correct permissions to do pushes here.

georgpfolz commented 2 years ago

At the moment I use deploy keys with my own repositories. Last time I tried without a deploy key it didn't work.. But that's probably only because I'm not very familiar with GitHub (I'm on gitlab for my private repositories).

I'll check it out (may take some time)...

d-maurer commented 2 years ago

Georg Pfolz wrote at 2022-6-26 01:22 -0700:

At the moment I use deploy keys with my own repositories.

I had to create an "access token" (and give it the right permissions) on github.

My .gitconfig:

[user]
    name = dieter
    email = EMAIL

[credential "https://github.com"]
    username = d-maurer
    helper = store

My .git-credentials:

https://d-maurer:ACCESS_TOKEN
georgpfolz commented 2 years ago

@d-maurer Thank you, that worked! PR created.