Following older discussions about generating IDs for holidays (e.g., for database storage), I came up with the structure:
{country};{state};{region};{rule}
This produces IDs like:
HK;;chinese 01-0-02 not on Sunday
This approach works well in most cases, but breaks in years where substitute holidays apply.
For example:
- In 2025 (Hong Kong), a holiday is returned with the rule:
chinese 01-0-02 not on Sunday
- In 2024, the corresponding holiday is returned as:
substitutes chinese 01-0-02 if Sunday then next Tuesday
Because the rule string changes, the generated ID is not stable across years for what is effectively the same holiday.
This makes it difficult to store and match holidays in a database reliably.
Question:
What is the recommended or canonical way to generate stable, year-independent IDs for holidays, especially in cases involving substitute rules?
Is there an internal identifier or normalization strategy that should be used instead of relying on the rule string?
Following older discussions about generating IDs for holidays (e.g., for database storage), I came up with the structure:
{country};{state};{region};{rule}This produces IDs like:
HK;;chinese 01-0-02 not on SundayThis approach works well in most cases, but breaks in years where substitute holidays apply.
For example:
chinese 01-0-02 not on Sundaysubstitutes chinese 01-0-02 if Sunday then next TuesdayBecause the rule string changes, the generated ID is not stable across years for what is effectively the same holiday.
This makes it difficult to store and match holidays in a database reliably.
Question:
What is the recommended or canonical way to generate stable, year-independent IDs for holidays, especially in cases involving substitute rules?
Is there an internal identifier or normalization strategy that should be used instead of relying on the rule string?