Skip to main content

FlexibleDate

This package can parse potentially dirty date data to create a FlexibleDate object. This package can also compare FlexibleDate objects to give them a score on how close they are to one another. Finally, this package can combine various FlexibleDates for the same event into a FlexibleDate that best represents all date information about that event.

Parsing

The package can parse strings for any day, month, or year information. If any of these attributes are not found, they are set to None.

from FlexibleDate.FlexibleDate import createFlexibleDate, FlexibleDate

fd:FlexibleDate = createFlexibleDate('Do you remember the 21st night of sep?')
print(fd) # None-9-21
print(fd.__repr__()) # FlexibleDate(likelyYear=None, likelyMonth=9, likelyDay=21)

Comparing FlexibleDates

It is often very useful to check how close two dates are, especially given two dates for the same event might be written different, usually because of an accident in remembering day, month, or year. Therefore, it can be useful to check how close the dates are using a scoring system.

Two FlexibleDate objects could potentially be describing the same event, even when they are not identical, especially in the case of birth dates on headstones, as the person who knew it best has no way to correct the relative who is ordering the engraving.

The attributes likelyDay and likelyMonth are compared using the absolute value distance between their respective counterparts in the other FlexibleDate. On the otherhand, the part of the score for likelyYear is based on the difference between the two years, with the score assigned logarithmically staggered based on how far back it is (as records often get less reliable the farther back you go). A positive score is generally a good indicator that the FlexibleDates are not drastically different.

from FlexibleDate.FlexibleDate import compareTwoDates, FlexibleDate

fdA = FlexibleDate(likelyDay=21, likelyMonth=9, likelyYear=1900)
fdB = FlexibleDate(likelyDay=None, likelyMonth=9, likelyYear=1902)

score = compareTwoDates(fdA, fdB)
print(score) # 20.0

Combining FlexibleDates

If there are various (sometimes slightly off) FlexibleDates for a specific event (someone's birth, for example), it can be useful to have a diffinitive FlexibleDate that best represents the event.

from FlexibleDate.FlexibleDate import createFlexibleDate, combineFlexibleDates

fdA = createFlexibleDate('Do you remember the 21st night of sep?')
fdB = createFlexibleDate('22 September 2024')
fdC = createFlexibleDate('21 Octo')

dates = [fdA, fdB, fdC]

fdD = combineFlexibleDates(dates=dates)
print(fdD) # 2024-9-21

Enjoy!

Metadata

Release files for FlexibleDate 1.0.33

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for FlexibleDate 1.0.33
File Size Uploaded
flexibledate-1.0.33.tar.gz 21.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for FlexibleDate 1.0.33
File Interpreter ABI Platform
flexibledate-1.0.33-py3-none-any.whl Python 3 none any Details

Total release size: 33.4 kB

Release files / flexibledate-1.0.33.tar.gz

Download URL flexibledate-1.0.33.tar.gz
Size 21.6 kB
Tags Source
SHA-256 checksum
How to use checksums
094862d94d7c6dfc0f11e6c6acd4cb15ffdb7cabf5749b3f645f728a81493623
BLAKE2b-256 checksum
How to use checksums
07f24c7618fa344ade4951b06ec70d2b5b2d7c14538c3463191f079879111064
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / flexibledate-1.0.33-py3-none-any.whl

Download URL flexibledate-1.0.33-py3-none-any.whl
Size 11.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e53e4d9d3e37d688a025ad5229be45baaf5017d5156e1adfb82503569d273a30
BLAKE2b-256 checksum
How to use checksums
814e442750b6c8312d00a91a3c4973d678a8632b7e887fd256362495cbdffa63
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

This release

1.0.33 This release

2 release files

1.0.25

2 release files

1.0.24

2 release files

1.0.23

2 release files

1.0.21

2 release files

1.0.14

2 release files

1.0.13

2 release files

1.0.9

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page