Moment.js issue
Moment.js issue
Hi Allan,
similar to the issue I had with format 'L' there is another problem when I trie to use format 'LT'.
LT should be this for German dates: LT: 'HH:mm' and this for English UK dates: LT : 'HH:mm'. Thank god it happens to be the same in this case! For that reason I hard coded it now like this:
{
label: "Bid Period End Time:",
name: "bidEndTime",
attr: {
class: timeMask
},
type: "datetime",
def: function () { return endOfDay },
format: 'HH:mm',
}
I would prefer to use format: 'LT' because I will be in trouble once I'll add an additional language if I do it like above.
If I use format 'LT' a date picker opens instead of the time picker. Probably becaus of the initial 'L'?! Do you have a fix for this please.
This question has accepted answers - jump to:
Answers
So in Moment
L
means a local date format, butLT
means a local time format. Bummer.That's not going to be a trivial thing to find unfortunately since I'll need to change how Editor detects the format - its using a simple string detection at the moment, checking to see if
L
is present.I'll look into this and get back to you - probably next week now.
Allan
Thanks Allan. Take your time! In each locale you find a definition like these two for 'en-gb' and 'de':
All those L ... formats would need to work I am afraid ... Hope it's not too much hassle. This is the American default if you have no locale specified:
What I really would like is a function in moment that would convert the locale based format to a "standard" formatting string (i.e. a lookup). I had a look through the Moment documentation but couldn't see anything about that. That would make the problem really easy .
Allan
So the answer is that it would technically be possible to deformat the locale formatting options (
L
,LT
,LL
,l
, etc) in the same way that Moment does it (it doesn't expose an API method for this externally), but as far as I can see it would mean needing to access some private data, which I don't want to do.So looking for a better way I've just used improved regular expressions for the detection.
A small modification to the part of Editor we changed before is:
I think in the short term that's possibly as close as I'm going to get. Longer term deformatting it by locale would be preferable.
Allan
Forgot to say - this will be in 1.6.2.
Allan