Sorry, I know this is not prototype related, but I was wondering if any one know of any libraries for dealing with date strings in JS. I am looking for something that does the equivalent to phps date() function.. I found a couple http://www.svendtofte.com/code/date_format/ http://www.mattkruse.com/javascript/date/source.html But both are buggy and produce unreliable results.. I think I might have to resort to doing this server side via ajax and PHP ... Seems odd that JS has such bad support for dealing with dates.. And odder still that no one has developed a solutions for it.. Cheers. ______________________________________________________________________ Alex Duffield --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Date is one of the 5 native subtypes of objects in JS... but it''s not totally intuitive for those of us wanting to do simple date related functions. It would be nice if someone wrote a nice clean high level wrapper around the Date object. Here''s a good reference that has helped me before: http://www.javascriptkata.com/2007/04/27/mastering-of-the-date-object-in-javascript/ On 6/4/07, Alex Duffield <Alex-GLL9njBnHiGqPKKiFzS5XxZCeNDtXRbv@public.gmane.org> wrote:> > > Sorry, I know this is not prototype related, but I was wondering if > any one know of any libraries for dealing with date strings in JS. > > I am looking for something that does the equivalent to phps date() > function.. > > I found a couple > http://www.svendtofte.com/code/date_format/ > > http://www.mattkruse.com/javascript/date/source.html > > But both are buggy and produce unreliable results.. > > I think I might have to resort to doing this server side via ajax and > PHP ... Seems odd that JS has such bad support for dealing with > dates.. And odder still that no one has developed a solutions for it.. > > Cheers. > ______________________________________________________________________ > Alex Duffield > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
On Jun 4, 11:13 am, Alex Duffield <A...-GLL9njBnHiGqPKKiFzS5XxZCeNDtXRbv@public.gmane.org> wrote:> http://www.mattkruse.com/javascript/date/source.html > But both are buggy and produce unreliable results..A more current and functional version of the above lib can be found at: http://www.JavascriptToolbox.com/lib/date/ I would be interested to hear of what bugs or unreliable results you have found. Both libs have been used extensively in a lot of production code and products. Sometimes users report errors when using a date format with "mm" for months (actually minutes) instead of "MM" and thinking the output is wrong, for example. Matt Kruse --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Matt, I was using this on a calendar in an app I am building. each td in the calendar has an id of "date.YYYY-MM-DD" Clicking on the cell triggers my function...(minimized for this example) var foobar = function(el){ var date = el.id.replace("date.", ""); var time = date.split("-"); var d = new Date(time[0], time[1], time[2]); $(elid).value = el.id; $(''formated'').value = d.format("EE MMM d, yyyy"); } When I select the cell for Friday Aug 3 2007 for example, I see elid = date.2007-08-03 -- formated = Monday September 3, 2007 I have used your date.js file in other applications and it has worked great for me, (Mostly comparing dates) But this time I cant get it working.. Its far more lickly that there is a flaw in my laginc above then in your lib, so if you could point it out to me, I would be most grateful!! Cheers ______________________________________________________________________ Alex Duffield ❖ Principal ❖ InControl Solutions . http:// www.incontrolsolutions.com On 4-Jun-07, at 10:53 AM, Matt Kruse wrote:> > On Jun 4, 11:13 am, Alex Duffield <A...-GLL9njBnHiGqPKKiFzS5XxZCeNDtXRbv@public.gmane.org> wrote: >> http://www.mattkruse.com/javascript/date/source.html >> But both are buggy and produce unreliable results.. > > A more current and functional version of the above lib can be found > at: > http://www.JavascriptToolbox.com/lib/date/ > > I would be interested to hear of what bugs or unreliable results you > have found. Both libs have been used extensively in a lot of > production code and products. Sometimes users report errors when using > a date format with "mm" for months (actually minutes) instead of "MM" > and thinking the output is wrong, for example. > > Matt Kruse > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Hey guys, I''m probably missing something simple. I''m requesting some data on the back-end, and return a JSON string. The JSON string returned is exactly, for example: {"FName":"Mark","LName":"Holton","EmailAddress":"holtonma-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org ","Phone":4255555555} I can return that JSON string and stuff it into any dom element with Ajax.Updater without a problem. But I''d like to pass the data into the function using Ajax.Request, then populate elements on the page, such as $(''txFirstName'').value = jsonobj.FName; $(''txLastName'').value jsonobj.LName; etc. There must be something wrong with how I''m trying to do this, however, as I''m getting no response when using Ajax.Request, whereas I am able to display the json in a DOM element when using Ajax.Updater. I''m wondering if it''s because Updater sees the text string okay, yet, in order for JS to parse the incoming JS I have to do so with a header?: <!-- this isn''t working for me --> function PopulateViaSID(SID) { var passSID = encodeURIComponent(parseInt(SID)); var pars = ''FORM.passSID ='' + passSID ; new Ajax.Request() var url ''/SShow/Model/AjaxCalls/sshow_caller_populateRef.cfm''; new Ajax.Request(url, { method: ''get'', onSuccess: function(transport, json) { alert(json ? Object.inspect(json) : "no JSON object"); // no alert displays when I try this } }); <!-- this does return the string from the server and populate a DOM element --> new Ajax.Updater(resultDomElem, ''/Skillshow/Model/AjaxCalls/skillshow_caller_populateRef.cfm'', { asynchronous:true, parameters: pars, onSuccess:function(){ $(''txtRefNotes'').value = ''hello''; //this worked // $(''txtRefFirstName'').value = oUser.FName; //was hoping I could do this, but it didn''t work Element.setOpacity(resultDomElem, 0.0); Effect.Appear(resultDomElem, { duration: 0.5 }); new Effect.Highlight(resultDomElem, {startcolor:CEB195, endcolor:F8F8D2}); } } ); --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
On Jun 4, 1:27 pm, Alex Duffield <A...-GLL9njBnHiGqPKKiFzS5XxZCeNDtXRbv@public.gmane.org> wrote:> Matt, I was using this on a calendar in an app I am building. each td > in the calendar has an id of "date.YYYY-MM-DD" > var d = new Date(time[0], time[1], time[2]);Here is the problem. The Date() constructor takes months as 0=January. So you are passing in "8" thinking it should be August, but in fact that means month 9, which is September. Hope that helps, Matt Kruse --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Matt, I have posted a test case up here: http://www.greatspots.com/tests/cal.php Selecting on any of the "Single days" in the cal call the function.. (July 27 - Aug 31st) Any help is greatly appreciated! ______________________________________________________________________ Alex Duffield ❖ Principal ❖ InControl Solutions . http:// www.incontrolsolutions.com On 4-Jun-07, at 10:53 AM, Matt Kruse wrote:> > On Jun 4, 11:13 am, Alex Duffield <A...-GLL9njBnHiGqPKKiFzS5XxZCeNDtXRbv@public.gmane.org> wrote: >> http://www.mattkruse.com/javascript/date/source.html >> But both are buggy and produce unreliable results.. > > A more current and functional version of the above lib can be found > at: > http://www.JavascriptToolbox.com/lib/date/ > > I would be interested to hear of what bugs or unreliable results you > have found. Both libs have been used extensively in a lot of > production code and products. Sometimes users report errors when using > a date format with "mm" for months (actually minutes) instead of "MM" > and thinking the output is wrong, for example. > > Matt Kruse > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Ah.. that is sill.. but oh well.. I should have been using your Date.parseString() function in the first place.. I used var d = Date.parseString(date, "yyyy-MM-dd"); and that fixed everything.. Sorry for slagging your lib... I should have know the error was on my side! Cheers. ______________________________________________________________________ Alex Duffield ❖ Principal ❖ InControl Solutions . http:// www.incontrolsolutions.com On 4-Jun-07, at 12:07 PM, Matt Kruse wrote:> > On Jun 4, 1:27 pm, Alex Duffield <A...-GLL9njBnHiGqPKKiFzS5XxZCeNDtXRbv@public.gmane.org> wrote: >> Matt, I was using this on a calendar in an app I am building. each td >> in the calendar has an id of "date.YYYY-MM-DD" >> var d = new Date(time[0], time[1], time[2]); > > Here is the problem. The Date() constructor takes months as 0=January. > So you are passing in "8" thinking it should be August, but in fact > that means month 9, which is September. > > Hope that helps, > > Matt Kruse > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---