Accueil > > > CHOIX DE DATES ET DE PERIODE
CHOIX DE DATES ET DE PERIODE
Information sur la source
Description
Ce code vous permet d'envoyer par formulaire une periode avec ses dates limites, tres utile pour des pages de stats. Au format YYYYMMJJ, mais tres facilement modifiable.
Source
- <HTML>
- <HEAD>
- <TITLE></TITLE>
- <SCRIPT>
- var Today = new Date()
- var Days = new Array("Dimanche","Lundi","Mardi","Mercredi","Jeudi","Vendredi","Samedi")
- var Months = new Array("Janvier","F¨¦vrier","Mars","avril","Mai","Juin","Juillet","Aout","Septembre","Octobre","Novembre","Décembre")
- var msc_day = 1000*60*60*24
- // retourne la date au format "JJ/MM/AAAA"
- function DateFormat_French(JscDate){
- var sDay = JscDate.getDate() < 10 ? "0" + JscDate.getDate() : JscDate.getDate()
- var sMonth = JscDate.getMonth()+1 < 10 ? "0" + (JscDate.getMonth()+1) : JscDate.getMonth()+1
- return(sDay + "/" + sMonth + "/" + JscDate.getFullYear())
- }
- // retourne la date au format "AAAAMMJJ"
- function DateFormat_Serial(JscDate){
- var sDay = JscDate.getDate() < 10 ? "0" + JscDate.getDate() : JscDate.getDate()
- var sMonth = JscDate.getMonth()+1 < 10 ? "0" + (JscDate.getMonth()+1) : JscDate.getMonth()+1
- return(""+JscDate.getFullYear() + sMonth + sDay)
- }
- // retourne la date du premier jour de la semaine (1 = lundi)
- function Week_FirstDay(FromDate){
- var TestDate = new Date()
- for (j=0; j<=7; j++){
- TestDate.setTime(FromDate.getTime()-(msc_day*j))
- if(TestDate.getDay() == 1){return(TestDate)}
- }
- }
- // retourne le num¨¦ro de la semaine
- function GetWeekNumber(FromDate){
- var tDate = new Date()
- tDate.setTime(FromDate.getTime())
- tDate = Week_FirstDay(tDate)
- for (w=0; w<53; w++){
- if (tDate.getFullYear() != FromDate.getFullYear()){return(w)}
- tDate.setTime(tDate.getTime()-(msc_day*7))
- }
- }
- function ShowDates(Type, iFromNow){
- var DateStart = new Date()
- var DateEnd = new Date()
- var iIndex = 0
- var sTitle = ""
-
- if (Type == "day"){ // type jour donc : d¨¦but de la semaine
- DateStart = Week_FirstDay(DateStart)
- DateStart.setTime(DateStart.getTime()-(msc_day*7*iFromNow))
- DateEnd.setTime(DateStart.getTime()+(msc_day*6))
- sTitle = "Semaine n¡ã " + GetWeekNumber(DateStart)
- }
- else if (Type == "week"){// type semaine donc : d¨¦but et fin de mois
- DateStart.setDate(1)
- for (i=0;i<iFromNow;i++){
- DateStart.setDate(-1)
- DateStart.setDate(1)
- }
- sTitle = Months[DateStart.getMonth()]
- DateEnd.setTime(DateStart.getTime())
- DateEnd.setDate(33)
- DateEnd.setDate(0)
- DateStart = Week_FirstDay(DateStart)
- iIndex = GetWeekNumber(DateStart)
- }
- else if (Type == "month"){// type mois donc : d¨¦but et fin d'ann¨¦e
- var DateStart = new Date()
- DateStart.setDate(1)
- for (i=0;i<iFromNow;i++){
- DateStart.setYear(DateStart.getYear()-1)
- }
- DateStart.setDate(1)
- DateStart.setMonth(0)
- DateEnd.setTime(DateStart.getTime())
- DateEnd.setMonth(11)
- DateEnd.setDate(31)
- iIndex = 1
- sTitle = "Ann¨¦e " + DateStart.getFullYear()
- }
-
- var shtml = "<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH='100%'>"
- + "<TR><TD COLSPAN=2 ALIGN='center'>"
- + "<A CLASS='ch_PeriodCursor' HREF=\"javascript: ShowDates('"+Type+"', "+(iFromNow+1)+")\">¡û</A> "
- if (iFromNow > 0)
- {shtml += "<A CLASS='ch_PeriodCursor' HREF=\"javascript: ShowDates('"+Type+"', "+(iFromNow-1)+")\">¡ú</A>"}
- else
- {shtml += "<SPAN CLASS='ch_PeriodCursor Disable'>¡ú</SPAN>"}
- shtml += "</TD></TR>"
- shtml += "<TR><TD COLSPAN=2 CLASS='ch_IntervalTitle'>" + sTitle + "</TD></TR>"
-
- var cDate = new Date()
- var DateEndPeriod = new Date() // fin de la p¨¦riode
- var TodaySerial = DateFormat_Serial(Today) // date d'aujourd'hui au format AAAAMMJJ
- cDate.setTime(DateStart.getTime())
- while (DateFormat_Serial(cDate) <= DateFormat_Serial(DateEnd)){
- var cDateSerial = DateFormat_Serial(cDate) // date courante au format AAAAMMJJ
- if (Type == "day"){
- DateEndPeriod.setTime(cDate.getTime())
- iIndex = cDate.getDate()
- sName = Days[cDate.getDay()]
- }
- else if(Type == "week"){
- DateEndPeriod.setTime(cDate.getTime()+(msc_day*6))
- sName = DateFormat_French(cDate)
- iIndex = GetWeekNumber(cDate)
- }
- else if(Type == "month"){
- DateEndPeriod.setTime(cDate.getTime())
- DateEndPeriod.setDate(33)
- DateEndPeriod.setDate(0)
- sName = Months[cDate.getMonth()]
- }
- if (iIndex < 10){iIndex = "0" + iIndex}
-
- if (DateFormat_Serial(cDate) <= TodaySerial){
- js = "SelectDate("+DateFormat_Serial(cDate)+","+DateFormat_Serial(DateEndPeriod)+",'"+Type+"');"
- sName = "<SPAN CLASS='ch_Index'>" + iIndex + " </SPAN><A ID=\"DateSel\" NAME=\"DateSel\" onclick=\"SelectLink()\" CLASS='ch_Link' STYLE=\"width: 70px\" HREF=\"javascript: "+js+"\">" + sName + "</A>"
- }
- else
- {
- sName = "<SPAN CLASS='ch_Index Disable'>" + iIndex + " </SPAN><SPAN CLASS='ch_Link Disable' STYLE=\"width: 70px\">" + sName + "</SPAN>"
- }
-
- shtml += "<TR><TD>" + sName + "</TD></TR>"
-
- if (Type == "day"){
- cDate.setTime(cDate.getTime()+(msc_day*1))
- }
- else if(Type == "week"){
- cDate.setTime(cDate.getTime()+(msc_day*7))
- }
- else if(Type == "month"){
- cDate.setDate(33)
- cDate.setDate(1)
- iIndex++
- }
- }
- Dates.innerHTML = shtml
- }
-
- function SelectDate(Start, End, sType){
- DateStart.value = Start
- DateFinish.value = End
- Type.value = sType
- }
-
- function SelectLink(){
- oCol = document.getElementsByName(window.event.srcElement.id)
- sClass = "ch_Link"
- for (i=0; i<oCol.length; i++){oCol[i].className = "ch_Link"}
- window.event.srcElement.className = "ch_Link Selected"
- }
- </SCRIPT>
- <STYLE>
- .ch_Title{font: 12 Arial; text-align: center; font-weight: bold; background-color: #DDDDDD}
- .ch_Content{background-color: #F5F5F5; vertical-align: top;}
- .ch_Link{padding-left: 5; padding-right: 5; font: 12 Arial; width: 100%; text-decoration: none;}
- .ch_Link:hover{background-color: #FFFFCC; color: #0000AA;}
- .ch_Index{font: 10 Arial; color: #000000}
- .ch_PeriodCursor{font: 16 Arial; width: 30; font-weight: bold;; text-decoration: none;}
- .ch_IntervalTitle{font: 12 Arial; text-align: center; font-weight: normal;}
- .Selected{background-color: #6699CC; color: #FFFFFF}
- .Disable{cursor: default; color: #AAAAAA;}
- </STYLE>
- </HEAD>
- <BODY>
-
- <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=1 STYLE="table-layout: fixed">
- <COL WIDTH=70><COL WIDTH=85>
- <TR CLASS="ch_Title"><TD>P¨¦riode</TD><TD>Interval</TD></TR>
- <TR>
- <TD CLASS="ch_Content">
-
- <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
- <TR><TD><A ID="Period" NAME="Period" onclick="SelectLink()" CLASS="ch_Link" HREF="javascript: ShowDates('day', 0)">Jours</A></TD></TR>
- <TR><TD><A ID="Period" NAME="Period" onclick="SelectLink()" CLASS="ch_Link" HREF="javascript: ShowDates('week', 0)">Semaines</A></TD></TR>
- <TR><TD><A ID="Period" NAME="Period" onclick="SelectLink()" CLASS="ch_Link" HREF="javascript: ShowDates('month', 0)">Mois</A></TD></TR>
- </TABLE>
-
- </TD>
- <TD ID="Dates" CLASS="ch_Content"> </TD>
- </TR>
- </TABLE>
-
- R¨¦sultat :<BR>
- Date d¨¦but : <INPUT TYPE="text" ID="DateStart" NAME="DateStart"><BR>
- Date Fin : <INPUT TYPE="text" ID="DateFinish" NAME="DateFinish"><BR>
- Type : <INPUT TYPE="text" ID="Type" NAME="Type"><BR>
- </BODY>
- </HTML>
<HTML>
<HEAD>
<TITLE></TITLE>
<SCRIPT>
var Today = new Date()
var Days = new Array("Dimanche","Lundi","Mardi","Mercredi","Jeudi","Vendredi","Samedi")
var Months = new Array("Janvier","F¨¦vrier","Mars","avril","Mai","Juin","Juillet","Aout","Septembre","Octobre","Novembre","Décembre")
var msc_day = 1000*60*60*24
// retourne la date au format "JJ/MM/AAAA"
function DateFormat_French(JscDate){
var sDay = JscDate.getDate() < 10 ? "0" + JscDate.getDate() : JscDate.getDate()
var sMonth = JscDate.getMonth()+1 < 10 ? "0" + (JscDate.getMonth()+1) : JscDate.getMonth()+1
return(sDay + "/" + sMonth + "/" + JscDate.getFullYear())
}
// retourne la date au format "AAAAMMJJ"
function DateFormat_Serial(JscDate){
var sDay = JscDate.getDate() < 10 ? "0" + JscDate.getDate() : JscDate.getDate()
var sMonth = JscDate.getMonth()+1 < 10 ? "0" + (JscDate.getMonth()+1) : JscDate.getMonth()+1
return(""+JscDate.getFullYear() + sMonth + sDay)
}
// retourne la date du premier jour de la semaine (1 = lundi)
function Week_FirstDay(FromDate){
var TestDate = new Date()
for (j=0; j<=7; j++){
TestDate.setTime(FromDate.getTime()-(msc_day*j))
if(TestDate.getDay() == 1){return(TestDate)}
}
}
// retourne le num¨¦ro de la semaine
function GetWeekNumber(FromDate){
var tDate = new Date()
tDate.setTime(FromDate.getTime())
tDate = Week_FirstDay(tDate)
for (w=0; w<53; w++){
if (tDate.getFullYear() != FromDate.getFullYear()){return(w)}
tDate.setTime(tDate.getTime()-(msc_day*7))
}
}
function ShowDates(Type, iFromNow){
var DateStart = new Date()
var DateEnd = new Date()
var iIndex = 0
var sTitle = ""
if (Type == "day"){ // type jour donc : d¨¦but de la semaine
DateStart = Week_FirstDay(DateStart)
DateStart.setTime(DateStart.getTime()-(msc_day*7*iFromNow))
DateEnd.setTime(DateStart.getTime()+(msc_day*6))
sTitle = "Semaine n¡ã " + GetWeekNumber(DateStart)
}
else if (Type == "week"){// type semaine donc : d¨¦but et fin de mois
DateStart.setDate(1)
for (i=0;i<iFromNow;i++){
DateStart.setDate(-1)
DateStart.setDate(1)
}
sTitle = Months[DateStart.getMonth()]
DateEnd.setTime(DateStart.getTime())
DateEnd.setDate(33)
DateEnd.setDate(0)
DateStart = Week_FirstDay(DateStart)
iIndex = GetWeekNumber(DateStart)
}
else if (Type == "month"){// type mois donc : d¨¦but et fin d'ann¨¦e
var DateStart = new Date()
DateStart.setDate(1)
for (i=0;i<iFromNow;i++){
DateStart.setYear(DateStart.getYear()-1)
}
DateStart.setDate(1)
DateStart.setMonth(0)
DateEnd.setTime(DateStart.getTime())
DateEnd.setMonth(11)
DateEnd.setDate(31)
iIndex = 1
sTitle = "Ann¨¦e " + DateStart.getFullYear()
}
var shtml = "<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH='100%'>"
+ "<TR><TD COLSPAN=2 ALIGN='center'>"
+ "<A CLASS='ch_PeriodCursor' HREF=\"javascript: ShowDates('"+Type+"', "+(iFromNow+1)+")\">¡û</A> "
if (iFromNow > 0)
{shtml += "<A CLASS='ch_PeriodCursor' HREF=\"javascript: ShowDates('"+Type+"', "+(iFromNow-1)+")\">¡ú</A>"}
else
{shtml += "<SPAN CLASS='ch_PeriodCursor Disable'>¡ú</SPAN>"}
shtml += "</TD></TR>"
shtml += "<TR><TD COLSPAN=2 CLASS='ch_IntervalTitle'>" + sTitle + "</TD></TR>"
var cDate = new Date()
var DateEndPeriod = new Date() // fin de la p¨¦riode
var TodaySerial = DateFormat_Serial(Today) // date d'aujourd'hui au format AAAAMMJJ
cDate.setTime(DateStart.getTime())
while (DateFormat_Serial(cDate) <= DateFormat_Serial(DateEnd)){
var cDateSerial = DateFormat_Serial(cDate) // date courante au format AAAAMMJJ
if (Type == "day"){
DateEndPeriod.setTime(cDate.getTime())
iIndex = cDate.getDate()
sName = Days[cDate.getDay()]
}
else if(Type == "week"){
DateEndPeriod.setTime(cDate.getTime()+(msc_day*6))
sName = DateFormat_French(cDate)
iIndex = GetWeekNumber(cDate)
}
else if(Type == "month"){
DateEndPeriod.setTime(cDate.getTime())
DateEndPeriod.setDate(33)
DateEndPeriod.setDate(0)
sName = Months[cDate.getMonth()]
}
if (iIndex < 10){iIndex = "0" + iIndex}
if (DateFormat_Serial(cDate) <= TodaySerial){
js = "SelectDate("+DateFormat_Serial(cDate)+","+DateFormat_Serial(DateEndPeriod)+",'"+Type+"');"
sName = "<SPAN CLASS='ch_Index'>" + iIndex + " </SPAN><A ID=\"DateSel\" NAME=\"DateSel\" onclick=\"SelectLink()\" CLASS='ch_Link' STYLE=\"width: 70px\" HREF=\"javascript: "+js+"\">" + sName + "</A>"
}
else
{
sName = "<SPAN CLASS='ch_Index Disable'>" + iIndex + " </SPAN><SPAN CLASS='ch_Link Disable' STYLE=\"width: 70px\">" + sName + "</SPAN>"
}
shtml += "<TR><TD>" + sName + "</TD></TR>"
if (Type == "day"){
cDate.setTime(cDate.getTime()+(msc_day*1))
}
else if(Type == "week"){
cDate.setTime(cDate.getTime()+(msc_day*7))
}
else if(Type == "month"){
cDate.setDate(33)
cDate.setDate(1)
iIndex++
}
}
Dates.innerHTML = shtml
}
function SelectDate(Start, End, sType){
DateStart.value = Start
DateFinish.value = End
Type.value = sType
}
function SelectLink(){
oCol = document.getElementsByName(window.event.srcElement.id)
sClass = "ch_Link"
for (i=0; i<oCol.length; i++){oCol[i].className = "ch_Link"}
window.event.srcElement.className = "ch_Link Selected"
}
</SCRIPT>
<STYLE>
.ch_Title{font: 12 Arial; text-align: center; font-weight: bold; background-color: #DDDDDD}
.ch_Content{background-color: #F5F5F5; vertical-align: top;}
.ch_Link{padding-left: 5; padding-right: 5; font: 12 Arial; width: 100%; text-decoration: none;}
.ch_Link:hover{background-color: #FFFFCC; color: #0000AA;}
.ch_Index{font: 10 Arial; color: #000000}
.ch_PeriodCursor{font: 16 Arial; width: 30; font-weight: bold;; text-decoration: none;}
.ch_IntervalTitle{font: 12 Arial; text-align: center; font-weight: normal;}
.Selected{background-color: #6699CC; color: #FFFFFF}
.Disable{cursor: default; color: #AAAAAA;}
</STYLE>
</HEAD>
<BODY>
<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=1 STYLE="table-layout: fixed">
<COL WIDTH=70><COL WIDTH=85>
<TR CLASS="ch_Title"><TD>P¨¦riode</TD><TD>Interval</TD></TR>
<TR>
<TD CLASS="ch_Content">
<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
<TR><TD><A ID="Period" NAME="Period" onclick="SelectLink()" CLASS="ch_Link" HREF="javascript: ShowDates('day', 0)">Jours</A></TD></TR>
<TR><TD><A ID="Period" NAME="Period" onclick="SelectLink()" CLASS="ch_Link" HREF="javascript: ShowDates('week', 0)">Semaines</A></TD></TR>
<TR><TD><A ID="Period" NAME="Period" onclick="SelectLink()" CLASS="ch_Link" HREF="javascript: ShowDates('month', 0)">Mois</A></TD></TR>
</TABLE>
</TD>
<TD ID="Dates" CLASS="ch_Content"> </TD>
</TR>
</TABLE>
R¨¦sultat :<BR>
Date d¨¦but : <INPUT TYPE="text" ID="DateStart" NAME="DateStart"><BR>
Date Fin : <INPUT TYPE="text" ID="DateFinish" NAME="DateFinish"><BR>
Type : <INPUT TYPE="text" ID="Type" NAME="Type"><BR>
</BODY>
</HTML>
Historique
- 18 juillet 2004 17:49:22 :
- bug sur l'affichage du titre
Sources de la même categorie
Commentaires et avis
|
Derniers Blogs
ZUNE : NOUVELLE VERSION DU ZUNE SOFTWARE - V 4.2ZUNE : NOUVELLE VERSION DU ZUNE SOFTWARE - V 4.2 par ROMELARD Fabrice
Avec la dernière génération du lecteur MP3 de Microsoft, le ZUNE HD, Microsoft a publié une nouvelle version du logiciel pour PC. Ainsi, je me suis décidé à installer celle-ci sur mon Tablet PC ACER, comme toujours le logiciel est donc tél...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice L'INTERFACE NATURELLE DE WINDOWS PHONE 7 SERIESL'INTERFACE NATURELLE DE WINDOWS PHONE 7 SERIES par odewit
La tendance est aux interfaces naturelles (NUI), et le keynote de Bill Buxton au MIX l'a bien souligné.
La charte graphique et ergonomique de Windows Phone 7 a donc été entièrement repensée en vue d'obtenir un maximum d'efficacité sur ce point. En re...
Cliquez pour lire la suite de l'article par odewit COMMENT MAPPER UNE VUE SQL SUR UNE COLLECTION DE COMPLEX TYPE?COMMENT MAPPER UNE VUE SQL SUR UNE COLLECTION DE COMPLEX TYPE? par Matthieu MEZIL
Avec EF, les vues doivent être mappées sur des entity types. Le problème c'est que les entity types doivent avoir une clé. Avec EF, nous avons les complex type qui n'ont pas de clé mais les vues ne peuvent pas être mappées dessus. Avec EF4, il est possibl...
Cliquez pour lire la suite de l'article par Matthieu MEZIL
Logiciels
Academy System (10.9.4.0)ACADEMY SYSTEM (10.9.4.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System Xilisoft Convertisseur Vidéo Ultimate (5.1.39.0305)XILISOFT CONVERTISSEUR VIDéO ULTIMATE (5.1.39.0305)Xilisoft Convertisseur Vidéo Ultimate est un outil puissant de conversion vidéo, facile à utilise... Cliquez pour télécharger Xilisoft Convertisseur Vidéo Ultimate Xilisoft DVD Ripper Ultimate (5.0.64.0304)XILISOFT DVD RIPPER ULTIMATE (5.0.64.0304)Xilisoft DVD Ripper Ultimate est un logiciel excellent pour copier et convertir DVD vers presque ... Cliquez pour télécharger Xilisoft DVD Ripper Ultimate Rigs of Rods (63.3)RIGS OF RODS (63.3)c'est un jeu de multi-simulation camions,autobus voitures, avions, bateaux, hélicoptère avec défo... Cliquez pour télécharger Rigs of Rods
Comparez les prix

HTC Magic
Entre 429€ et 429€
|