Version compl�te: jsB@nk » » Date Trieuse script
URL: https://www.javascriptbank.com/date-sorter-script.html
Cet JavaScript sera une sorte de tableau avec les dates du mois précisé. Elle se fait par la conversion de la date dans un format plus facile à gérer.
Version compl�te: jsB@nk » » Date Trieuse script
URL: https://www.javascriptbank.com/date-sorter-script.html
<script>// Patrick Lewis ([email protected])// #### DateSorter v1.0// #### by Patrick Lewis// Sample DatesStartDates = new Array("Sep 18, 2003","Jun 5, 2001","Aug 27, 2003","Dec 22, 2002","Aug 9, 2001","May 31, 2002","Sep 26, 2003","Apr 26, 2001","Sep 9, 2003");Sign = new Array();Sign["new"] = ">";Sign["old"] = "<";months=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");function ConvertDate(DT){// Date format should be "MMM DD, YYYY" M = DT.substring(0,DT.indexOf(" "));D = DT.substring(DT.indexOf(" ")+1,DT.indexOf(","));Y = DT.substring(DT.lastIndexOf(" ")+1,DT.length);if (D.length == 1) {D = "0"+D;}for (l=0;l<12;l++) {if (months[l] == M) {M = l+1; break;}}if (M < 10) {M = "0"+M;}return Y+""+M+""+D;}function Sort(How){for (z=0;z<StartDates.length-1;z++) {for (y=0;y<(StartDates.length-(z+1));y++) {if ( eval(ConvertDate(StartDates[y+1])+ Sign[How] +ConvertDate(StartDates[y])) ) {temp=StartDates[y+1]; StartDates[y+1] = StartDates[y]; StartDates[y]=temp;}}}// Load Sorted dates into textareadocument.Date.Sorted.value = "";for (x=0;x<StartDates.length;x++) {document.Date.Sorted.value += StartDates[x]+"\r\n";}}// Load Sample dates into textareadocument.Date.Start.value = "";for (x=0;x<StartDates.length;x++) {document.Date.Start.value += StartDates[x]+"\r\n";}</script><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->
<form name=Date><table border=0 width=525><tr><th colspan=3> Date Sorter </th></tr><tr><td width=175 align=middle>Scrammbled dates<br><textarea cols=15 rows=10 name=Start></textarea></td><td align=middle width=175><input type=button value="Sort ascending" onclick="Sort('old')"><br><br><input type=button value="Sort descending" onclick="Sort('new')"></td><td width=175 align=middle>Sorted Dates<br><textarea cols=15 rows=10 name=Sorted></textarea></td></tr></table></form><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->