madmg / moment-jdateformatparser Goto Github PK
View Code? Open in Web Editor NEWTranslates the `java.text.SimpleDateFormat` date format to the `moment.js` date format.
License: MIT License
Translates the `java.text.SimpleDateFormat` date format to the `moment.js` date format.
License: MIT License
the java-date-pattern 'w' is mapped to 'W' which is the ISO-week.
that's not correct.
'w' should stay 'w'
Hi,
When using moment-jdateformatparser with webpack, webpack throws an error in the section where moment-jdateformatparser is trying to determine whether the environment is node or AMD.
not sure about a solution but i thought i would send you guys a heads up about it
here is the warning as it comes from webpack
WARNING in .//moment-jdateformatparser/moment-jdateformatparser.js/moment-jdateformatparser/moment-jdateformatparser.js 163:78-85
Critical dependencies:
163:78-85 require function is used in a way in which dependencies cannot be statically extracted
@ ./
Hi,
I used "yyy" in my java code, it works like that (99 -> 099 , 999-> 999 , 9999->9999).
can you please provide a way to Map 'yyy' in momentjs?
thanks
I'm using the following code to load moment-jdateformatparser
:
require.config({
paths: {
'moment': 'path/to/moment',
'moment-jdateformatparser': 'path/to/moment-jdateformatparser'
},
shim: {
'moment-jdateformatparser': ['moment']
}
});
require(['moment', 'moment-jdateformatparser'], function(moment) {
moment().toMomentFormatString('yyyy/MM/dd HH:mm');
});
This fails from time to time complaining that toMomentFormatString
is not available. It happens most often on IE11. The issue is that moment-jdateformatparser
extends moment
using a Require.js callback when require is available (even if moment was previously loaded). Require.js doesn't call the callback immediately but on the next processor cycle (think about setTimeout(0)) even if the required module is already loaded. Thus you have to do this to make it work, which is cumbersome:
require(['moment-jdateformatparser'], function() {
// moment-jdateformatparser was loaded but it didn't extend moment yet.
// We need to put our code in a require callback in order to wait for
// moment-jdateformatparser to extend moment.
require(['moment'], function(moment) {
moment().toMomentFormatString('yyyy/MM/dd HH:mm');
});
});
The mappings contains several errors. I've translated your library to Java and removed many of the bugs. Plus, I've added support for escaped characters. I suggest to back-port these fixes to your library.
Hi. Are there some issues with node 6?
I'm trying to run code
require('moment-jdateformatparser');
(0, _moment2.default)().toMomentFormatString(format);
but getting error TypeError: (0 , _moment2.default)().toMomentFormatString is not a function
Code (0 , _moment2.default)()
returns object of type 'Moment'.
Using the version 1.1.0
of jdateformatparser with requirejs (using requirejs 2.3.2
on my side) results in an Uncaught ReferenceError
on execution of the module in line 181:
Uncaught ReferenceError: module is not defined
at moment-jdateformatparser.js:181
at moment-jdateformatparser.js:250
This is broken since the check for module
was changed with this commit from
if (typeof module !== 'undefined' && typeof module.exports !== 'undefined')
to
if (module && module.exports)
Quoted strings are interpret incorrectly.
SimpleDateFormat:
System.out.println(new SimpleDateFormat("d.' of 'MMM").format(new Date()));
prints out _14. of Feb_ when:
console.log(moment().formatWithJDF("d.' of 'MMM"));
prints _14.' of 'Feb_
when I call time.tz(""America/New_York"").formatWithJDF("yyyy/MM/dd HH:mm:ss z"), I got this:
2018/06/01 08:00:00 -0400
which I expected:
2018/06/01 08:00:00 EDT
Hi,
I recently found that after an upgrade to Angular 1.3.9 some of the standard AngularJS $locale DATETIME_FORMATS were no longer converting properly to the moment equivalent. It turns out that many of the DATETIME_FORMATS strings were converted to use the single 'y' representation of the year instead of the 'yyyy'.
It seems a little odd but unlike the 'yy' string, this should result in full display of the year (just with no padding 0s for years of fewer than 4 digits).
From the angular locale docs:
'y': 1 digit representation of year, e.g. (AD 1 => 1, AD 199 => 199)
It appears that SimpleDateFormat exhibits the same behaviour.
It looks like there isn't an exact equivalent of 'y' in momentjs format strings but the addition of the javaFormatMapping - y: 'YYYY' might provide an approximation.
Thanks
Hi Team,
I use the latest package in angular 6.
npm install moment-jdateformatparser.
But i got error with momentjs.fn is not defined when testing with simple format:
moment().formatWithJDF('DD');
I am not sure if the import is wrong:
import * as moment from 'moment-jdateformatparser';
I am at your disposal.
Hi,
Any chance you can add support for k and K?
H Hour in day (0-23) Number 0
k Hour in day (1-24) Number 24
K Hour in am/pm (0-11) Number 0
h Hour in am/pm (1-12) Number 12
I am getting the date as: ex: 3/11/2011
I am assigning a bunch of dates into an array "U" and then dumping it into a datable.
var resolution = moment(data.d.results[u].Resolution_x0020_Due).format('l hh:mm A');
data.d.results[u].Resolution_x0020_Due = resolution + " < img style='padding-left: 20px;' title='SLA is currently on time' src='sla_good.png'/ > ";
When I want to add and image to that string it returns invalid date. Is there a way to add an image without getting invalid date back?
the character 'A' to lowercase 'a' in toJDFString
moment().toJDFString("h:mm A")
returns "h:mm A"
and is not a valid java.text.SimpleDateFormat pattern
repl: https://repl.it/@marcusmotill/moment-jdateformatparser-bug
code:
let moment = require('moment');
let momentJdateformatparser = require('moment-jdateformatparser');
console.log(moment().formatWithJDF("dd.MM.yyyy"))
output:
+ [email protected]
+ [email protected]
added 3 packages in 1.998s
Repl.it: package installation success
TypeError: moment(...).formatWithJDF is not a function
at evalmachine.<anonymous>:4:22
at Script.runInContext (vm.js:74:29)
at Object.runInContext (vm.js:182:6)
at evaluate (/run_dir/repl.js:137:14)
at Socket.<anonymous> (/run_dir/repl.js:120:5)
at Socket.emit (events.js:180:13)
at addChunk (_stream_readable.js:274:12)
at readableAddChunk (_stream_readable.js:261:11)
at Socket.Readable.push (_stream_readable.js:218:10)
at Pipe.onread (net.js:581:20)
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.