Comments (8)
Workaround for this is to replace SimpleDateFormat quotes with square brackets before passing the formatString into formatWithJDF method.
e.g.
var end = false;
var fixed = formatString.replace(/\'/g, function(match) {
return (end = !end) ? '[' : ']';
});
from moment-jdateformatparser.
hey @anttileppa - thanks a lot for raising this issue and sorry for the long delay on answering your question/issue. if you have already an existing solution to the problem I'd ask you to open a PR so that we can include your fix into our next release - this would be awesome 👍
from moment-jdateformatparser.
the workaround doesn't work for the following pattern
yyyy-MM-dd[T]HH:mm:ss.SSS[Z]
the 'Z' is translated to ZZ
from moment-jdateformatparser.
I can't see any quotes in the pattern you posted @gerpres ? The workaround @anttileppa posted was for "escaping" quotes 😃
from moment-jdateformatparser.
sorry for that :-)
the pattern:
yyyy-MM-dd'T'HH:mm:ss.SSS'Z'
doesn't work.
neither with '' nor with []
the Z inside the quotation is always replaced by ZZ
from moment-jdateformatparser.
ah, I see! thank you - I'll take a look at it and see what I can come up with in order to make the string escaping work 👍
from moment-jdateformatparser.
have a look at...
moment.fn.toMomentFormatString = function (formatString) {
if (!javaDateFormats[formatString]) {
var mapped = "";
var regexp = /[^']+|('[^']*')/g;
while((part = regexp.exec(formatString))) {
part = part[0];
if(part.match(/'.?'/)) {
mapped+="["+part.substring(1,part.length-1)+"]";
} else {
mapped+=translateFormat(part, javaFormatMapping)
}
}
javaDateFormats[formatString] = mapped
}
return javaDateFormats[formatString];
};
from moment-jdateformatparser.
closing due to the merge of PR #19 🥇
from moment-jdateformatparser.
Related Issues (15)
- Single 'y' representation of year HOT 1
- Adding an image to the string date returns invalid date HOT 1
- Using 'yyy' in formatString HOT 2
- Support for k,K HOT 1
- webpack cannot statically wire moment HOT 7
- week pattern maps to ISO-week
- toMomentFormatString function with node v6.7.0 HOT 5
- Wrong mappings HOT 3
- Loading with Require.js doesn't always work as expected HOT 3
- java.lang.IllegalArgumentException: Illegal pattern character 'A' HOT 3
- Uncaught ReferenceError: module is not defined HOT 1
- Doesn't support moment timezone well
- After 1.2.0 update getting TypeError: moment(...).formatWithJDF is not a function breaking builds HOT 2
- momentjs.fn is not defined. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from moment-jdateformatparser.