Skip to content

Negative date do not display correctly in the widget and are considered invalid in the result #771

@Voldenuix

Description

@Voldenuix

After updating Sparnatural on the 11.0 version in OpenArcheao, the display of a negative date in the date widget seems broken.
It'd automatically change the negative date to a positive one :

Image Image

While in the SPARQL query everything seems fine :
Image

The negative dates will also be showned as « Invalid Date » in the result :

Image

After some research, the problem might comes from the way ValueLabel is handled in DateWidget.ts :

    let lbl = "";

    if (start != "" && start) {
      lbl = lbl.concat(` ${start.toISOString().slice(0, 10)}`);
    }
    if (stop && stop != "") {
      lbl = lbl.concat(` - ${stop.toISOString().slice(0, 10)}`);
    }
    return lbl;
  };

The .toISOSting() function convert the String to a Javascript Date format, which doesn't support negative dates (hence the Invalid Date result).
It might be interesting to add a check if the start or stop date is negative, in order to keep it as a string and not use the toISOString() function.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions