Dates
How the API formats timestamps, dates, and years
A record in Valise can have timestamps, partial dates, or a year. Timestamps say when a record was created and when it last changed. Partial dates say when a presentation opened and closed, and can be a year, a month, or a day. An artwork’s year is text, as the artist typed it.
The API returns all three as strings. Fields ending in At are timestamps, fields ending in Date are partial dates, and an artwork’s year is text:
| Record | Field | Format | Example |
|---|---|---|---|
| All records | createdAt, updatedAt | Timestamp in UTC | 2024-09-06T11:17:15Z |
| Uploads | createdAt, uploadFile.expiresAt | Timestamp in UTC | 2024-09-06T11:17:15Z |
| Presentations | startDate, endDate | Partial date: a year, a month, or a day | 2024-05 |
| Artworks | year | Text, as the artist entered it | c. 2023 |
Valise sets the timestamps itself, and a request can’t change them. Artists enter partial dates and years in Valise, and the API returns them exactly as they were entered. It doesn’t fill in missing parts or convert one format to another.
Timestamps
Every record has a createdAt and an updatedAt: when the record was added to Valise, and when it last changed. Uploads are the exception. An upload has a createdAt but no updatedAt, and the response that creates it has an uploadFile.expiresAt for when its upload URL stops working.
A timestamp is an RFC 3339 time in UTC, to the whole second:
{
"createdAt": "2024-09-06T11:17:15Z",
"updatedAt": "2024-11-02T08:40:03Z"
}
The Z at the end means UTC. The API doesn’t send timestamps in another timezone, or with fractions of a second.
A timestamp is about the record in Valise. For when an artwork was made, read its year, which is text. For when a presentation ran, read its startDate and endDate, which are partial dates.
Most languages read this format without extra work. In JavaScript, pass the string to new Date(), then format it in the timezone you want to show:
const createdAt = new Date("2024-09-06T11:17:15Z")
createdAt.toLocaleString("en-US", { timeZone: "America/New_York" })
// "9/6/2024, 7:17:15 AM"
Partial dates
A presentation’s startDate and endDate are the dates it opened and closed. Artists often don’t know the exact day, especially for older exhibitions, so Valise lets them enter a year or a month instead. The API returns each date at the precision the artist entered:
| The artist entered | The API returns |
|---|---|
| 2024 | "2024" |
| May 2024 | "2024-05" |
| May 10, 2024 | "2024-05-10" |
| Nothing | "" |
The API never fills in the missing parts. A presentation dated May 2024 comes back as 2024-05, and never as 2024-05-01. Both fields are always in the response, and each has its own precision: a presentation can open on 2024-03-10 and close in 2024-05.
When you show a partial date, show only the parts it has: “May 2024” for 2024-05. Showing “May 1, 2024” would name a day the artist never gave.
Reading dates
Most date libraries expect a full day. Given a partial date, they either reject it or fill in the first of the month or year.
In JavaScript, new Date() reads all three forms as midnight UTC on the first day of the period. That goes wrong when you format the date in a timezone behind UTC, like any in the Americas. Midnight UTC is still the evening before there, so the date prints as the day before. For a year, it prints as the year before:
const newYork = { timeZone: "America/New_York" }
new Date("2024-05-10").toLocaleDateString("en-US", newYork) // "5/9/2024"
new Date("2024-05").toLocaleDateString("en-US", newYork) // "4/30/2024"
new Date("2024").toLocaleDateString("en-US", newYork) // "12/31/2023"
We recommend splitting the value on its hyphens to see which parts it has, then formatting only those parts. Format them in UTC so the day doesn’t shift in the reader’s timezone:
const formatPartialDate = (value, locale = "en-US") => {
if (!value) return ""
const [year, month, day] = value.split("-").map(Number)
const date = new Date(Date.UTC(year, (month ?? 1) - 1, day ?? 1))
return date.toLocaleDateString(locale, {
timeZone: "UTC",
year: "numeric",
month: month ? "long" : undefined,
day: day ? "numeric" : undefined,
})
}
formatPartialDate("2024") // "2024"
formatPartialDate("2024-05") // "May 2024"
formatPartialDate("2024-05-10") // "May 10, 2024"
The exhibition history example uses this function to format each presentation’s dates.
Sorting
Partial dates sort in date order as plain text, so you don’t need to parse them first. A year sorts before the months in it, and a month before its days: 2024, then 2024-05, then 2024-05-10. An empty string sorts before every date.
The API lists presentations by when they were created in Valise, newest first. An artist filling in their exhibition history rarely adds shows in the order they happened, so sort the list yourself to put it in date order. In JavaScript, this sorts presentations by start date, newest first, with undated ones last:
presentations.sort((a, b) => b.startDate.localeCompare(a.startDate))
Sending dates
When you create or update a presentation, send dates in the same three forms the API returns:
{
"venue": "Gallery One",
"type": "solo",
"startDate": "2024-03-10",
"endDate": "2024-05"
}
Leave a field out if you don’t know the date. In an update, a date you leave out keeps its saved value, and an empty string clears it. A date in any other form, like 05/10/2024, or one that doesn’t exist, like 2024-13, gets a 400.
The end date can’t be before the start date. An end date that’s a year or a month covers that whole period: a presentation that opened on 2024-03-10 can end in 2024, and can’t end in 2023.
If an update sends only one of the two dates, the API checks it against the other one as saved, and the 400 names the date you sent. A start date that’s too late gets “Must not be after the end date.” on startDate, and an end date that’s too early gets this on endDate:
{
"error": {
"code": "bad_request",
"message": "The request is invalid.",
"details": [
{ "field": "endDate", "message": "Must not be before the start date." }
]
}
}
Artwork years
An artwork’s year is text, up to 100 characters, as the artist typed it: 2022, c. 2023, 1990–1992, Early 1960s. Artists often give an approximate year, a range for a piece made over several years, or a decade for early work.
Show the year as written. Reading it as a number fails on most of these: Number("c. 2023") is NaN, and parseInt("1990–1992") drops the end of the range.
If you need a number, to sort artworks or group them by decade, take the first four digits and keep the text for display:
const firstYear = (year) => Number(year.match(/\d{4}/)?.[0]) || null
firstYear("c. 2023") // 2023
firstYear("1990–1992") // 1990
firstYear("Early 1960s") // 1960
firstYear("Undated") // null