I'm not sure I understand the use case. You can write your own parsers as you like, right? Is it that you want to ensure that a given value is used with a specific parser? I think that's a reasonable feature to require. If that's what you're after, open a lighthouse ticket for it?
On Tue, Feb 1, 2011 at 6:21 AM, Neilime <[email protected]> wrote: > Is there any way to define a specific parser when Date.parse is used ? > > My solution if another not exists (But not effective as well because > of build function only exists in mootools.more file) : > > Date.extend({ > parse: function(from,parser){ > var t = $type(from); > if (t == 'number') return new Date(from); > if (t != 'string') return from; > from = from.clean(); > if (!from.length) return null; > > var parsed; > if(parser == null){ > parsePatterns.some(function(pattern){ > var bits = pattern.re.exec(from); > return (bits) ? (parsed = pattern.handler(bits)) : > false; > }); > } > else{ > partern = build(parser); > var bits = pattern.re.exec(from); > parsed = (bits) ? (pattern.handler(bits)) : false; > } > > return parsed || new Date(nativeParse(from)); > } > }); > > console.log(Date.parse('10/12/2010','%d/%m/%Y( %H:%M)?') >
