gravity-ui / date-utils Goto Github PK
View Code? Open in Web Editor NEWHelpers to manage work with dates.
License: MIT License
Helpers to manage work with dates.
License: MIT License
It would be useful to have a utility for working with the date in utc format. Something like the old version of working with a date or an analog in dayjs:
dayjs.utc('2023-12-31'); // '2023-12-31T00:00Z'
dayjs.utc('2023-12-31T00:00Z'); // '2023-12-31T00:00Z'
there is a difference between moment and dayjs APIs
dayjs().tz('Europe/Moscow').format('z') // 'GMT+3’
moment(Date.now()).tz('Europe/Moscow').zoneAbbr() // 'MSK’
it seems that it could be a good feature to support timezones abbreviations
I think we can extend dayjs functionality by adding some flag: abbreviateTimezone: true/false
and overriding .format()
method as following:
format('z')
returns GMT +3
, after that if abbreviateTimezone flag is turned on, we search through the result string and replace GMT +3
with provided abbreviations
date-utils itself could provide some default abbreviations, like GMT +3 = MSK
, however it would be great to have an ability to override default abbreviations
I selected Europe/Moscow time zone and tried to enter 12.03.2023, but the result was 12.02.2023
In luxon
it's very handy method Duration.toFormat
. It would be great to have such an ability in date-utils
.
support ability to create a duration
dayjs.duration({ months: 12 })
I suggest adding parentheses for keywords and adding new keywords instead of a separator, for example now => now()
, /d => today()
, /w => week()
, /M => month()
, /y => year()
. It will be more readable this way. Also, this syntax will be easier to convert.
Hello!
For example, I got '2024-01-01' and 'Europe/Moscow' and I want DateTime to be '2024-01-01T00:00:00+03:00'. Any way I could achieve this with dateTimeParse?
Issue in Vite vitejs/vite#14102
Proposal:
Get rid of variable here and add locales map, smth like:
const langs = {
ru: () => import(‘dayjs/locale/ru.js’),
…
};
and load locale in settings.loadLocale
:
await langs[locale]();
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.