Python-Gitlab - getting list of commits since 1 month ago

I am seeing weird behavior when trying to get commits older than a certain age.

        self.prune_age = '1 month ago'
        branchlist = self.project.branches.list(iterator=True)
        print(f"\nBranches that are eligible for purging (no updates since '{self.prune_age}')")
        branchlist = [branch for branch in branchlist if (branch.merged==True and branch.protected==False)]
        for branch in branchlist:
            commitList = self.project.commits.list(ref_name={}, since={self.prune_age}, iterator=True)            
            print(f"Branch {} has {len(commitList)} commits since {self.prune_age}.")
            commitList = self.project.commits.list(ref_name={}, iterator=True)
            for c in commitList:
                print(f"Branch {} last commit: {c}")


Branches that are eligible for purging (no updates since ‘1 month ago’)

Branch xxx-release/2.1.0-patch-82815 has 0 commits since 1 month ago.

Branch xxx-release/2.1.0-patch-82815 last commit: <class ‘gitlab.v4.objects.commits.ProjectCommit’> => {‘id’: ‘de78a7687071dcab01fced549d28199241b026e’, ‘short_id’: ‘de78a768’, ‘created_at’: ‘2023-01-04T21:23:10.000+00:00’, ‘parent_ids’: [‘9bf4e78c13f722c1ffa06e54d49e766080780d3’], ‘title’: ‘Update .gitlab-ci.yml’, ‘message’: ‘Update .gitlab-ci.yml’, ‘author_name’: 'Some User, ‘author_email’: ‘’, ‘authored_date’: ‘2023-01-04T21:23:10.000+00:00’, ‘committer_name’: ‘Some User’, ‘committer_email’: ‘’, ‘committed_date’: ‘2023-01-04T21:23:10.000+00:00’, ‘trailers’: {}, ‘web_url’: ‘’}

Obviously ‘committed_date’: ‘2023-01-04T21:23:10.000+00:00’ is less than a month ago, so why doesn’t it show up on initial query.

When I turn on debug mode I see the following:

send: b’GET /api/v4/projects/654654/repository/commits?ref_name=xxxx-release%2F2.1.0-patch-82815&since=1+month+ago HTTP/1.1\r\nHost:\r\nUser-Agent: python-gitlab/3.12.0\r\nAccept-Encoding: gzip, deflate\r\nAccept: /\r\nConnection: keep-alive\r\nPRIVATE-TOKEN: [MASKED]\r\nContent-type: application/json\r\nCookie: _cfuvid=nAKaWRwW8USvW2tV0uEJa8xPrwCNyGS2Wz0EmzWTOFg-15445454545-0-604800000\r\n\r\n’

Followed by:
header: Link:; rel=“first”,; rel=“last”

Where is the 1-16-2023 date coming from?

I think I figure out the issue. API can’t handle relative dates. :frowning:

You can use the ref_name, since and until filters to limit the results:

commits = project.commits.list(ref_name=‘my_branch’)
commits = project.commits.list(since=‘2016-01-01T00:00:00Z’)