AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

RrealDate-Format in Delphi nutzen

Ein Thema von thomasdrewermann · begonnen am 13. Mär 2004
Antwort Antwort
Benutzerbild von thomasdrewermann
thomasdrewermann

Registriert seit: 8. Jun 2002
Ort: Herne
575 Beiträge
 
Delphi 3 Professional
 
#1

RrealDate-Format in Delphi nutzen

  Alt 13. Mär 2004, 14:32
In meinem PHPBB Forum wird der Geburtstag eines Users mit Hilfe des Real-Date-Formates gespeichert.

Die PHP-Funktion zum Generieren sieht so aus:
Code:
function realdate($date_syntax="Ymd",$date=0)
{
   global $lang;
   $i=2;
   if ($date>=0)
   {
       return create_date($date_syntax,$date*86400+1,0);
   } else
   {
      $year= -(date%1461);
      $days = $date + $year*1461;
      while ($days<0)
      {
         $year--;
         $days+=365;
         if ($i++==3)
         {
            $i=0;
            $days++;
         }
      }
   }
   $leap_year = ($i==0) ? TRUE : FALSE;
   $months_array = ($i==0) ?
      array (0,31,60,91,121,152,182,213,244,274,305,335,366) :
      array (0,31,59,90,120,151,181,212,243,273,304,334,365);
   for ($month=1;$month<12;$month++)
   {
      if ($days<$months_array[$month]) break;
   }

   $day=$days-$months_array[$month-1]+1;
   //you may gain speed performance by remove som of the below entry's if they are not needed/used
   return strtr ($date_syntax, array(
      'a' => '',
      'A' => '',
      '\\d' => 'd',
      'd' => ($day>9) ? $day : '0'.$day,
      '\\D' => 'D',
      'D' => $lang['day_short'][($date-3)%7],
      '\\F' => 'F',
      'F' => $lang['month_long'][$month-1],
      'g' => '',
      'G' => '',
      'H' => '',
      'h' => '',
      'i' => '',
      'I' => '',
      '\\j' => 'j',
      'j' => $day,
      '\\l' => 'l',
      'l' => $lang['day_long'][($date-3)%7],
      '\\L' => 'L',
      'L' => $leap_year,
      '\\m' => 'm',
      'm' => ($month>9) ? $month : '0'.$month,
      '\\M' => 'M',
      'M' => $lang['month_short'][$month-1],
      '\\n' => 'n',
      'n' => $month,
      'O' => '',
      's' => '',
      'S' => '',
      '\\t' => 't',
      't' => $months_array[$month]-$months_array[$month-1],
      'w' => '',
      '\\y' => 'y',
      'y' => ($year>29) ? $year-30 : $year+70,
      '\\Y' => 'Y',
      'Y' => $year+1970,
      '\\z' => 'z',
      'z' => $days,
      '\\W' => '',
      'W' => '') );
}
Kennt jemand eine Delphi-Funktion zum dekodieren?

MFG
Thomas
Sport ist mord...
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 09:29 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz