{"id":17190740,"url":"https://github.com/stestagg/dateformat","last_synced_at":"2026-02-14T08:32:33.265Z","repository":{"id":60775455,"uuid":"113165866","full_name":"stestagg/dateformat","owner":"stestagg","description":"A simple, fast date parsing/formatting library for python","archived":false,"fork":false,"pushed_at":"2022-11-17T11:30:00.000Z","size":164,"stargazers_count":12,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-27T15:31:43.570Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stestagg.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-12-05T10:09:08.000Z","updated_at":"2022-11-17T11:30:31.000Z","dependencies_parsed_at":"2023-01-22T01:15:16.122Z","dependency_job_id":null,"html_url":"https://github.com/stestagg/dateformat","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/stestagg/dateformat","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stestagg%2Fdateformat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stestagg%2Fdateformat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stestagg%2Fdateformat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stestagg%2Fdateformat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stestagg","download_url":"https://codeload.github.com/stestagg/dateformat/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stestagg%2Fdateformat/sbom","scorecard":{"id":851981,"data":{"date":"2025-08-11","repo":{"name":"github.com/stestagg/dateformat","commit":"3a99e891e586d73fafca85b4c591966ebbc89b36"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}}]},"last_synced_at":"2025-08-23T22:46:28.927Z","repository_id":60775455,"created_at":"2025-08-23T22:46:28.927Z","updated_at":"2025-08-23T22:46:28.927Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29440390,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-14T07:24:13.446Z","status":"ssl_error","status_checked_at":"2026-02-14T07:23:58.969Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-15T01:23:48.019Z","updated_at":"2026-02-14T08:32:33.246Z","avatar_url":"https://github.com/stestagg.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dateformat ![build status](https://travis-ci.org/stestagg/dateformat.svg?branch=master)\n\n`dateformat` does two things:  turn `datetime` objects into strings, and turn strings into `datetime` objects.\nIt's goal is to do these things simply and well, and to satisfy the following criteria:\n\n * Be fast enough (see below for benchmarks)\n * Handle a variety of date formats from multiple sources\n * Parse and format dates in many timezones and with many timezone offsets\n * Represent the expected format in a way that a non-technical person may understand\n * Be explicit about the expected format to prevent heuristic errors\n\n\u003e \"But why another date library?\"\n\nThere isn't currently a python library I've been able to find that matches these \nrequirements well enough for my use-cases.  [`Arrow`](http://arrow.readthedocs.io/en/latest/)\n comes closest, but still isn't quite suitable performance-wise.\n\n# Usage\n\nAll functionality is based around DateFormat() objects:\n\n### `def __init__(self, spec, is_24hour=None)`\n\ncreate a dateformat object from the provided spec string.\n\n```\n\u003e\u003e\u003e from dateformat import DateFormat\n\n\u003e\u003e\u003e date_format = DateFormat(\"YYYY-MM-DD hh:mm:ss.SSSS+HH:MM\")\n```\n\nIf `is_24hour` is not provided, the format will be in 12-hour mode if an am/pm \npart is present in the spec, otherwise, dates will be in 24-hour mode.\n\nDateFormat instances have two methods:\n\n### `def parse(self, data)`\n\nParse a string(`data`) containing a date into a datetime object.\n\n```\n\u003e\u003e\u003e date = date_format.parse(\"2017-06-03 15:32:00.2364-02:00\")\ndatetime.datetime(2017, 6, 3, 15, 32, 0, 236400, tzinfo=datetime.timezone(datetime.timedelta(-1, 79200)))\n```\n\n### `def format(self, date)`\n\nFormat the passed in `datetime.datetime` object (`date`) as a string:\n\n```\n\u003e\u003e\u003e print(date_format.format(date))\n2017-06-03 15:32:00.2364-02:00\n```\n\n## Timezones\n\nIf any part of the format provides a timezone, or UTC offset, then parsing \nproduces dates with a timezone indicating the relevant UTC offset.\n\nLikewise, if a dateformat has a timezone part, then dates passed to `.format()`\nmust include a tzinfo value.\n\nIf pytz is available, then some level of named timezone support is provided.\n\n## Leading zeros\n\nAll numeric parts of the date format are zero-padded to the number of characters\nin the spec.  I.e.  'DD' means that the day of the month is zero-padded to 2-digits.\n\nDuring parsing, a missing leading zero is usually ignored, but if there is no separator\nbetween parts (for example:  YYYYMMDD), then a missing leading zero will cause an error or bad value.\n\nCurrently, all formatted dates are zero-padded, in the future, this may be controllable.\n\n## Date format specification\n| Part | Example | Description |\n|---------|---------|---------------|\n| `+HHMM` | -0515 | A UTC offset provided as a 2-digit hour, and 2-digit minute, with no separator |\n| `+HH:MM` | -05:15 | A UTC offset provided as a 2-digit hour, and 2-digit minute, with a ':' separator |\n| `+HH` | -05 | A UTC offset provided as a 2-digit hour only |\n| `Dddddd` | Monday | The full locale-specific day of the week (Note, this value is ignored during date parsing, but added during date format) |\n| `Ddd` | Mon | The locale-specific short name for the day of the week (Ignored during parsing) |\n| `DD` | 05 | The zero-padded day of the month. |\n| `MMMMM` | September | Month as locale’s full name |\n| `MMM` | Sep | Month as locale’s abbreviated name |\n| `MM` | 05 | The zero-padded month as number 1 - 12 |\n| `YYYY` | 2017 | Year with century as a number |\n| `YY` | 17 | Year without century as a zero-padded number |\n| `hh` | 09 | Hour as a zero-padded number |\n| `mm` | 06 | Minute as a zero-padded number |\n| `ss` | 45 | Second as a zero-padded number |\n| `SSSSSS` | 123456 | Microsecond as a zero-padded decimal number |\n| `SSSS`   | 1234 | 100-microseconds as a zero-padded number |\n| `SSS` | 123 | milliseconds as a zero-padded number |\n| `SS` | 12 | 10-milliseconds as a zero-padded number |\n| `am` `Am` `AM` `pm` `Pm` `PM` | am | either AM or PM depending on the hour.  `.format()` matches the case of the spec.  If present, the dateformat will default to 12-hour mode |\n| `of` | | Ignored during parsing, added during formtting |\n| `st` | th | The appropriate suffix for the day of the month, for example '1_st_ July', '2_nd_ March' |\n| `␣` | T | (Unicode OPEN BOX - U+2423) Matches either the character 'T' or a space ' '.  During formatting, 'T' is always used (this is provided to improve flexibility when parsing iso8601 formats) |\n| space | | Matches one or more spaces during parsing.  During formatting, one space will be output |\n| any of `:/-.,TZ()` | | Ignored during parsing, output as-is during formatting |\n\n\n# Examples\n\n| Format                   | Example                |\n|--------------------------|------------------------|\n| `YYYY-MM-DDThh:mm:ss`    | 2017-06-06T09:45:15    |\n| `YYYYMMDDhhmmss`         | 20170606094515         |\n| `YYYYMMDDhhmmss.SSSSSSZ` | 20170606094515.123456Z |\n| `MM/DD/YY hh:mm+HHMM`    | 06/06/17 09:45-0500    |\n\n\n# Library comparison\n\n## dateformat ⇄ datetime (builtin python module)\n\nDateformat is *not* trying to be a replacement for the builtin datetime module.  `datetime.datetime` objects are used as the input/output to the parsing and formatting methods.\n\nIt is designed as a replacement for the  `datetime.datetime.strftime` and `datetime.datetime.strptime` methods, providing:\n\n * better timezone handling\n * a simpler/more common syntax for specifying the date formats\n * slightly faster parsing\n\n## dateformat ⇄ dateutil.parser.parse()\n\n`dateutil.parser.parse`'s intent is to turn a string in an unknown format into a date.  It does that by using a variety of heuristics to try to figure out the format the date has been expressed in.\n\nThis approach is highly useful, and very flexible, but suffers from a couple of drawbacks that dateformat doesn't have:\n\n * There is ambiguity about what date will be produced from a given string, there are situations where that risk cannot be accepted, and it's important for the system to only accept a certain date format\n * Because of all the work that dateutil is doing to work out the format used, it's fairly slow, at just under 10x slower than `strptime`, this is very noticable over 10s - 100s thousands of dates.\n\n## dateformat ⇄ arrow\n\narrow is the closest to the way dateformat works, the syntax for describing dates is very similar. Unfortunately, arrow constructs its parser every time a date is parsed, creating a significant overhead when parsing each date.\n\n## dateformat ⇄ iso8601 / ciso8601\n\nciso8601 is _really_ fast.  Unfortunately both these libraries only handle a single date format, so are not useful in this situation.\n\n# Benchmarks\n\nthe `benchmark/` dir contains some simple scripts to show how the relative libraries perform at parsing and formatting dates.\n\nRunning on a 2016 macbook pro, on Python 3.6.3 gave the following results (best of 3 runs):\n\n(Please note, the parse time chart y-axis has been clamped to 1s, but dateparser took 16s to complete)\n\n![chart showing relative date parse performance](https://github.com/stestagg/dateformat/raw/master/benchmark/parse_times.png)\n\n![chart showing relative date format performance](https://github.com/stestagg/dateformat/raw/master/benchmark/format_times.png)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstestagg%2Fdateformat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstestagg%2Fdateformat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstestagg%2Fdateformat/lists"}