Skip to content

Support of Historical dates (years only)#3

Merged
kochrt merged 1 commit intomark-when:mainfrom
Deuh:bce-dates
Oct 12, 2024
Merged

Support of Historical dates (years only)#3
kochrt merged 1 commit intomark-when:mainfrom
Deuh:bce-dates

Conversation

@Deuh
Copy link
Contributor

@Deuh Deuh commented Oct 9, 2024

Implement support for historical date

This branch is to implement support for BCE/BC and CE/AD dates.
This implementation cover only the Year and will not works with month, day etc.

Note:

Implementation was done only with the added test to verify it's working. Maybe some additional testing would be needed

Changes

  • Add regex for the BCE dates
  • Add case where needed to parse BCE dates
  • Add Method to get Datetime from a year and its notation to cover that year 0 doesn't exist (we go from 1BCE to 1AD) but in javascript year 0 exist
  • Add Tests

Known issues:

  • AD dates are supposed to be formatted with AD then Year (AD 70). For simplicity and to align with other notation AD should be after the year: "5 AD: Some event"
  • Currently you cannot mix and match EDF/Event dates and BCE dates. It means you cannot have something like: "250BC - 01/01/70". You need to set "70 AD" or "70 CE"

Example:

Refer to tests/dates.test.ts to see some examples

Tests result:

Failing test are already failing on main branch:

# main branch
Test Suites: 2 failed, 5 passed, 7 total
Tests:       4 failed, 12 skipped, 476 passed, 492 total
Snapshots:   0 total
Time:        9.793 s

This branch

 PASS  tests/regex.test.ts (5.256 s)
 FAIL  tests/ical.test.ts (5.45 s)
 PASS  tests/recurrence.test.ts (5.455 s)
 PASS  tests/dates.test.ts (5.605 s)
 PASS  tests/entryProperties.test.ts (5.509 s)
 PASS  tests/zones.test.ts (5.568 s)
 FAIL  tests/header.test.ts (5.641 s)
 PASS  tests/main.test.ts (6.067 s)
 
Test Suites: 2 failed, 6 passed, 8 total
Tests:       4 failed, 12 skipped, 489 passed, 505 total
Snapshots:   0 total
Time:        6.788 s, estimated 7 s

Copy link
Member

@kochrt kochrt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, it's missing a couple things of course, like months and days like you pointed out, as well as event ids and relative dates/durations. But! that can be for another time.

Thank you for doing this!



/**
* NOTE: I find it weird that the expectedTo date is always the next day at 00:00:00. Shouldn't it be the same day at 23:59:59?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's an open range from the start up to but not including the end [from, to)

@kochrt kochrt merged commit aec91ff into mark-when:main Oct 12, 2024
@DickiSmits
Copy link

Hello dear hard workers,
I am wondering why you can't use "-" in stead of BC
As far i understand the [Extended Date Time Format] format shoud be: -0000/12/31 for a date Before Christ
Will it not work easyer that way?
Hope there will be a solution for it soon.
Thanks anyway!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants