Skip to content

Add an option to configure how the number of days is calculated #253

@multiwebinc

Description

@multiwebinc

Suppose we have the range 15.06.2016 23:59 ~ 16.06.2016 00:00. The length of time between the start and the end is only 1 second, however this library displays "2 days" because it spans across 2 separate calendar dates. I suggest adding a way to configure this.

Configuration option: daysMode('span' / 'nights' / 'period')

if (daysMode === 'span') {
    // Use the current behavior (default)
}
if (daysMode === 'nights') {
    // Should be the same as the current behavior minus 1. This is the number of
    // times the boundary between 23:59 and 00:00 is crossed
}
if (daysMode === 'period') {
    // The actual number of complete 24 hour periods between one datetime and 
    // another.
    // If we have Monday at 23:59 until Tuesday at 23:58 this should be 0, even 
    // though it crosses from one day to another.
}

I haven't looked at the code, but I can't see this being overly difficult to achieve. If you are interested let me know and I'll code it and submit a pull request.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions