[vienna.pm] Datums Konvertierungen

Philipp Gühring p.guehring at poboxes.com
Wed Feb 6 06:42:46 CST 2002


* * * vienna-pm-list * * *


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Am Mittwoch, 6. Februar 2002 12:38 schrieben Sie:
> On Wed, Feb 06, 2002 at 12:06:41PM +0100, Philipp Gühring wrote:
> > Ich hab Datumsangaben in folgendem Format:
> > $timestamp="Thu Aug 30 14:19:09 2001";
> > Was ich brauche sind folgende beiden Formate:
> > $xml="2002-02-02T12:43:39";
> > $epoch="1012921741";
> > Wir konvertiere ich das am einfachsten?
> > (Ich hab leider meine Perl Bücher gerade nicht zur Hand)
>
> Perldoc ist dein Freund:
> http://www.perldoc.com/perl5.6.1/lib/Date/Manip.html

Date::Manip war das einzigste Datums Modul, das ich auf CPAN nicht gefunden 
habe vorher. (Unter http://search.cpan.org/Catalog/Data_and_Data_Type/ sollte 
es doch eigentlich sein, oder?)

Für alle, dies interessiert hier nun der funktionierende Code:

while 
($in=~s{(.*?)<TIMESTAMP>(\w+\s*\w+\s*\d+\s*\d{2}:\d{2}:\d{2}\s*\d{4})</TIMESTAMP>}{}s)
{
  $out.=$1;
  my $date=&ParseDate($2);
$out.="<TIMESTAMP>".&UnixDate($date,"%Y-%m-%dT%H:%M:%S")."</TIMESTAMP>\n";
  $out.="  <EPOCH>". &UnixDate($date,"%s")."</EPOCH>";
}

Schöne Grüße,
- -- 
~ Philipp Gühring              p.guehring at futureware.at
~ http://www.livingxml.net/       ICQ UIN: 6588261
~ <xsl:value-of select="file:/home/philipp/.sig"/>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE8YSTIlqQ+F+0wB3oRAoUIAJ92EsCsPt32lgFtK/25e0qCYuZtdQCbBBa+
G4kC3AZ8a2ePv9Sirs6GhFw=
=9jV9
-----END PGP SIGNATURE-----
###
You are subscribed to vienna-pm-list as Philipp =?iso-8859-1?q?G=FChring?= <p.guehring at poboxes.com>
http://www.fff.at/fff/vienna.pm/



More information about the Vienna-pm mailing list