mcibique / vue-date-fns Goto Github PK
View Code? Open in Web Editor NEWDate filter for Vue based on the date-fns.
License: MIT License
Date filter for Vue based on the date-fns.
License: MIT License
Hi,
In my main.js I used to have (with version 1):
import {createDateFilter} from "vue-date-fns";
import locale from "date-fns/locale/nb";
...
Vue.filter("fullDateTime", createDateFilter("DD.MM.YYYY HH:mm:ss", {locale}));
After updating to version 2.0.0 of vue-date-fns I updated the format to:
Vue.filter("fullDateTime", createDateFilter("dd.MM.yyyy HH:mm:ss", {locale}));
Now I keep getting in console:
"vue.runtime.esm.js?2b0e:619 [Vue warn]: Error in render: "TypeError: formatDate is not a function""
with a reference to the index.js of the vue-date-fns package:
var formatDate = require("date-fns/format");
// https://date-fns.org/v2.14.0/docs/format#v2.0.0-breaking-changes
var DEFAULT_DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSSxxx";
function createDateFilter (defaultFormat, defaultOptions) {
return function dateFilter (date, format, opts) {
if (!date) {
return "";
}
return formatDate(date, format || defaultFormat || DEFAULT_DATE_FORMAT, Object.assign({}, defaultOptions || {}, opts));
};
}
Any suggestions what I might be doing wrong?
It's been a while since it came out. I'm not even sure if upgrading has any significant gains but I just wanna know your plans for this wrapper
This statement no longer works? import dateFilter from 'vue-date-fns';
I am getting this error: Error: 'default' is not exported by node_modules\vue-date-fns\src\index.js imported by <snip>...
This is what is in my package.json :
"date-fns": "^2.21.3",
"vue": "^2.6.11",
"vue-class-component": "^7.2.3",
"vue-date-fns": "^2.0.1",
Any thought?
@mcibique how can I pass the locale inside the vue template? The readme example is just in the js file
{{ new Date() | date("PPPP") }}
Is there a way to automatically use already defined and dynamically changed locales?
Some kind of automatic mapping since the locale names are the same.
https://vuetifyjs.com/en/features/internationalization/
https://vuetifyjs.com/en/features/internationalization/#vue-i18n
date-fns is on version 2.25.0
, is this using the same version?
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.