Nutrient Web SDK

ReferenceDateTimeStringCallback

Type Alias DateTimeStringCallback

Defining this callback allows you to customize how dates are rendered as part of the NutrientViewer UI.

Type Alias
Type Signature
type DateTimeStringCallback = (
    args: {
        dateTime: Date;
        element: "COMMENT_THREAD" | "ANNOTATIONS_SIDEBAR";
        object: AnnotationsUnion | NutrientViewer.Comment;
    },
) => string

Example

NutrientViewer.load({
dateTimeString: ({ dateTime, element }) => {
if(element === NutrientViewer.UIDateTimeElement.ANNOTATIONS_SIDEBAR) {
return new Intl.DateTimeFormat("en-US", {
dateStyle: "short",
timeStyle: "short",
}).format(dateTime);
} else {
return new Intl.DateTimeFormat("en-US", {
dateStyle: "full",
timeStyle: "long",
}).format(dateTime);
}
}
// ...
});

Type Declaration

Parameters

args
{ … }
  • dateTime: Date

    The date to be formatted.

  • element: "COMMENT_THREAD" | "ANNOTATIONS_SIDEBAR"

    The NutrientViewer UI element on which the date is going to be rendered.

  • object: AnnotationsUnion | NutrientViewer.Comment

    The annotation or comment that contains the date that is being rendered.

Returns

string