C:/Dev-Cpp/include/wx/wxDate/wx_DATE.cpp

Aller à la documentation de ce fichier.
00001 #ifndef __PROJETDATE_cpp__
00002 #define __PROJETDATE_cpp__
00003 
00004 #include "wx/wxDate/wx_date.h"
00005 #include <wx/datetime.h>
00006 #include <wx/string.h>
00008 // les zone V_Date sont de 8 carateres aaaammjj
00009 // pour les tries la compatibilé DB2 ... SQLITE
00010 // 00000000 etant des critéres de selection et que NULL pose de prblm
00011 
00012 
00013 wx_Date::wx_Date() {
00014                now = new wxDateTime; now->SetToCurrent();
00015                spn = new wxDateSpan();
00016                tst = new wxDateTime; tst->SetToCurrent();
00017              }; //initalisation *date current
00018  wx_Date::~wx_Date(){};
00019 
00020 
00021 // Return  wx_Date Message err
00022 wxString wx_Date::Merr() {return Derr;}
00023 // Return  wx_Date Formaté AAAA/MM/JJ edit mask
00024 wxString wx_Date::RdateE() {return now->Format("%Y/%m/%d");}
00025 // Return  wx_Date Formaté jj/MM/AAAA edit mask
00026 wxString wx_Date::RdateDMJ() {return now->Format("%d/%m/%Y");}
00027 // Return  wx_Date Formaté AAAAMMJJ Alpha
00028 wxString wx_Date::RdateA() {return now->Format("%Y%m%d");}
00029 // Return  wx_Date Formaté AAAAMMJJ Numérique
00030 size_t wx_Date::RdateN(wxString V_date) {return  wxAtoi(V_date.SubString(0, 7));}
00031 // Return  wx_Date Formaté AAAA
00032 wxString wx_Date::Ryear() {return now->Format("%Y");}
00033 // Return  wx_Date Formaté MM
00034 wxString wx_Date::Rmonth() { return now->Format("%m");}
00035 // Return  wx_Date Formaté JJ
00036 wxString wx_Date::Rday() {return now->Format("%d");}
00037 // Set Udate   wx_Date
00038 void wx_Date::Udate() { now->SetToCurrent(); }
00039 
00040 // Set  wx_Date  YYYYMMJJ
00041 bool wx_Date::Setdate(wxString V_date) {
00042 
00043 size_t ntest ;
00044 
00045 
00046     nyear  = wxAtoi(V_date.SubString(0, 3));
00047     nmonth = wxAtoi(V_date.SubString(4, 5));
00048     nday   = wxAtoi(V_date.SubString(6, 7));
00049 
00050  if ( nyear < 2000 ) return true;
00051  if ( nmonth == 0 || nmonth > 12 ) return true;
00052  if ( nday == 0 || nday > 31 ) return true;
00053 
00054 
00055 tst->ParseDate( wxT(V_date.SubString(0, 3)+"/"+V_date.SubString(4, 5)+"/"+ "01"));
00056 ntest =     GetNumberOfDays(tst->GetMonth(), tst->GetYear());
00057 if ( nday > ntest ) return true; // recherche si jour invalide exemple fevrier
00058 now->ParseDate( wxT(V_date.SubString(0, 3)+"/"+V_date.SubString(4, 5)+"/"+ V_date.SubString(6, 7)));
00059      return false;
00060 }
00061 // Set  wx_Date  JJ/MM/AAAA
00062 bool wx_Date::SetEdtDMY(wxString V_DMY) {
00063 
00064 size_t ntest ;
00065 
00066 
00067     nyear  = wxAtoi(V_DMY.SubString(6, 9));
00068     nmonth = wxAtoi(V_DMY.SubString(3, 4));
00069     nday   = wxAtoi(V_DMY.SubString(0, 1));
00070 
00071  if ( nyear < 2000 ) return true;
00072  if ( nmonth == 0 || nmonth > 12 ) return true;
00073  if ( nday == 0 || nday > 31 ) return true;
00074 
00075 
00076 tst->ParseDate( wxT(V_DMY.SubString(6, 9)+"/"+V_DMY.SubString(3, 4)+"/"+ "01"));
00077 ntest =     GetNumberOfDays(tst->GetMonth(), tst->GetYear());
00078 if ( nday > ntest ) return true; // recherche si jour invalide exemple fevrier
00079 now->ParseDate( wxT(V_DMY.SubString(6, 9)+"/"+V_DMY.SubString(3, 4)+"/"+ V_DMY.SubString(0, 1)));
00080      return false;
00081 }
00082 // Set  wx_Date  AAAA/MM/JJ
00083 bool wx_Date::SetEdtYMD(wxString V_YMD) {
00084 
00085 size_t ntest ;
00086 
00087 
00088     nyear  = wxAtoi(V_YMD.SubString(0, 3));
00089     nmonth = wxAtoi(V_YMD.SubString(5, 6));
00090     nday   = wxAtoi(V_YMD.SubString(8, 9));
00091 
00092  if ( nyear < 2000 ) return true;
00093  if ( nmonth == 0 || nmonth > 12 ) return true;
00094  if ( nday == 0 || nday > 31 ) return true;
00095 
00096 
00097 tst->ParseDate( wxT(V_YMD.SubString(0, 3)+"/"+V_YMD.SubString(5, 6)+"/"+ "01"));
00098 ntest =     GetNumberOfDays(tst->GetMonth(), tst->GetYear());
00099 if ( nday > ntest ) return true; // recherche si jour invalide exemple fevrier
00100 now->ParseDate( wxT(V_YMD.SubString(0, 3)+"/"+V_YMD.SubString(5, 6)+"/"+ V_YMD.SubString(8, 9)));
00101      return false;
00102 }
00103 // Contôle  wx_Date
00104 bool wx_Date::Ctrldate(wxString V_date) {
00105 
00106 size_t ntest ;
00107 Derr = "";
00108 
00109     nyear  = wxAtoi(V_date.SubString(0, 3));
00110     nmonth = wxAtoi(V_date.SubString(4, 5));
00111     nday   = wxAtoi(V_date.SubString(6, 7));
00112  if ( nyear == 0 ) { Derr = " Année " + V_date.SubString(0, 3) + " Invalide ->" + V_date ; return true; }
00113  if ( nmonth == 0 || nmonth > 12 ) {Derr = " Mois  " + V_date.SubString(4, 5) + " Invalide ->" +V_date; return true;}
00114  if ( nday == 0 || nday > 31 ) {Derr = " Jour  " + V_date.SubString(6, 7) + "  Invalide ->" + V_date; return true;}
00115 
00116 
00117 tst->ParseDate( wxT(V_date.SubString(0, 3)+"/"+V_date.SubString(4, 5)+"/"+ "01"));
00118 ntest =     GetNumberOfDays(tst->GetMonth(), tst->GetYear());
00119 // recherche si jour invalide exemple fevrier
00120 if ( nday > ntest ) { Derr = " Jour  " + V_date.SubString(6, 7) + "  Invalide ->" + V_date; return true;}
00121      return false;
00122 }
00123 
00124 
00125 // ADD Day to  wx_Date
00126 void wx_Date::AddDay(unsigned int V_day) {
00127 
00128 now->ParseDate( wxString::Format("%d/%02d/%02d",spn->GetYears(),spn->GetMonths(),spn->GetDays()));
00129 
00130      spn->SetYears(wxAtoi(now->Format("%Y")));
00131      spn->SetMonths(wxAtoi(now->Format("%m")));
00132      nday = wxAtoi(now->Format("%d"));
00133      spn->SetDays(nday + V_day);
00134 
00135 now->ParseDate( wxString::Format("%d/%02d/%02d",spn->GetYears(),spn->GetMonths(),spn->GetDays()));
00136 
00137 }
00138 
00139 // ADD Month to  wx_Date
00140 void wx_Date::AddMonth(unsigned int V_month) {
00141 
00142 now->ParseDate( wxString::Format("%d/%02d/%02d",spn->GetYears(),spn->GetMonths(),spn->GetDays()));
00143 
00144      spn->SetYears(wxAtoi(now->Format("%Y")));
00145      spn->SetDays(wxAtoi(now->Format("%d")));
00146      nmonth = wxAtoi(now->Format("%m"));
00147      spn->SetMonths(nmonth + V_month);
00148 
00149 now->ParseDate( wxString::Format("%d/%02d/%02d",spn->GetYears(),spn->GetMonths(),spn->GetDays()));
00150 
00151 }
00152 
00153 // ADD Year to  wx_Date
00154 void wx_Date::AddYear(unsigned int V_year) {
00155 
00156 now->ParseDate( wxString::Format("%d/%02d/%02d",spn->GetYears(),spn->GetMonths(),spn->GetDays()));
00157 
00158      spn->SetYears(wxAtoi(now->Format("%Y")) );
00159      spn->SetMonths(wxAtoi(now->Format("%m")));
00160      spn->SetDays(wxAtoi(now->Format("%d")));
00161      nyear =  wxAtoi(now->Format("%Y"));
00162      spn->SetMonths(nyear + V_year);
00163 
00164 now->ParseDate( wxString::Format("%d/%02d/%02d",spn->GetYears(),spn->GetMonths(),spn->GetDays()));
00165 
00166 }
00167 
00168 
00169 // Comp date Numerique return 1=*GT 0=EQ -1=*LT
00170 int  wx_Date::CompDate(size_t V_datex ,  size_t V_datey  ) {
00171 
00172 if (V_datex < V_datey) return -1;
00173 if (V_datex > V_datey) return 1;
00174 if (V_datex == V_datey) return 0;
00175 return 2;
00176 }
00177 
00178 wxString wx_Date::LongDateDMY(){
00179      syear = now->Format("%Y");
00180      nmonth = wxAtoi(now->Format("%m"));
00181     switch(nmonth)
00182    {
00183        case 1 : smonth = "Janvier"; break;
00184        case 2 : smonth = "Février"; break;
00185        case 3 : smonth = "Mars";break;
00186        case 4 : smonth = "Avril";break;
00187        case 5 : smonth = "Mai";break;
00188        case 6 : smonth = "Juin";break;
00189        case 7 : smonth = "Juillet";break;
00190        case 8 : smonth = "Août";break;
00191        case 9 : smonth = "Septembre";break;
00192        case 10 : smonth = "Octobre";break;
00193        case 11 : smonth = "Novembre";break;
00194        case 12 : smonth = "Décembre";break;
00195    }
00196 
00197   sday = now->GetWeekDayName(now->GetWeekDay(),Name_Abbr );
00198  if ( sday.Contains("Mon") == true) sday = "Lundi" ;
00199  if ( sday.Contains("Tue") == true) sday = "Mardi" ;
00200  if ( sday.Contains("Wed") == true) sday = "Mercredi" ;
00201  if ( sday.Contains("Thu") == true) sday = "Jeudi" ;
00202  if ( sday.Contains("Fri") == true) sday = "Vendredi" ;
00203  if ( sday.Contains("Sat") == true) sday = "Samedi" ;
00204  if ( sday.Contains("Sun") == true) sday = "Dimanche" ;
00205   return    sday + " " + now->Format("%d") + " " + smonth + " " + syear;;
00206 }
00207 
00208 wxString wx_Date::LongDateMY(){
00209      syear = now->Format("%Y");
00210      nmonth = wxAtoi(now->Format("%m"));
00211     switch(nmonth)
00212    {
00213        case 1 : smonth = "Janvier";break;
00214        case 2 : smonth = "Février";break;
00215        case 3 : smonth = "Mars";break;
00216        case 4 : smonth = "Avril";break;
00217        case 5 : smonth = "Mai";break;
00218        case 6 : smonth = "Juin";break;
00219        case 7 : smonth = "Juillet";break;
00220        case 8 : smonth = "Août";break;
00221        case 9 : smonth = "Septembre";break;
00222        case 10 : smonth = "Octobre";break;
00223        case 11 : smonth = "Novembre";break;
00224        case 12 : smonth = "Décembre";break;
00225    }
00226 
00227   return     smonth + " " + syear;;
00228 }
00229 
00230 #endif
00231 
00232 //wx_Date *Pdate= new wx_Date;

Généré le Fri Aug 4 12:09:10 2006 pour wx_Date par  doxygen 1.4.6-NO