const today = new Date();
const formattedDate = date_fns.format(today, 'E', {
locale: de,
});
console.info(formattedDate);
and a few other combinations but I can’t get it to recognise the locale, I have tried different countries and all the possible codes in other words for Germany I have tried all the following options:
The reason I want this is as I don’t want Monday to say Monday but Montag (as an example). It is possible that using eee instead of E will do this for me but hard for me to test.
I was trying to a avoid a function but I guess I may have to.
The date-fns library is provided in Tape already so we don’t normally need to import (and to be honest I tried importing the locale just in case and it errored) so for example, all of this works with no import or required:
thanks for reaching out and for bringing up this issue. Also thanks to @tape-triangle for stepping in and sharing your insights.
Indeed, in order to provide and use a different locale than the default (en-US english), one needs to use the exported locales from the date-fns/locale export of the library:
import { de, enUS } from 'date-fns/locale';
This is also the way that we use internally in the Tape source code - as the whole application leverages date_fns (a nice synergy effect with workflow automations and our amazing community) to format dates across our web apps and also server side. However, in Tape automations, as the code runs inside a sandbox, one cannot simply import or require external depencies - for security and performance reasons.
As those exports carry extra weight in terms of byte size - think of every language including wordings etc. as a few bytes extra - and as we aim to keep the workflow sandbox as lightweight as possible, the locales are currently not included there.
While we would not rule out the option to include them in the future, this would currently be lower prio. Feel free to create a feature request to enhance the workflow code sandbox with date-fn locales. We do see the value, and similar to adding extra libraries (which is something we have done in the past) adding sub components to existing libraries is feasible.