Giter Site home page Giter Site logo

Comments (8)

anttileppa avatar anttileppa commented on June 29, 2024

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.

herom avatar herom commented on June 29, 2024

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.

gerpres avatar gerpres commented on June 29, 2024

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.

herom avatar herom commented on June 29, 2024

I can't see any quotes in the pattern you posted @gerpres ? The workaround @anttileppa posted was for "escaping" quotes 😃

from moment-jdateformatparser.

gerpres avatar gerpres commented on June 29, 2024

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.

herom avatar herom commented on June 29, 2024

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.

gerpres avatar gerpres commented on June 29, 2024

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.

herom avatar herom commented on June 29, 2024

closing due to the merge of PR #19 🥇

from moment-jdateformatparser.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.