I'm parsing a database description for a Progress database, and I want to create an importer for Oracle for an exported flatfile. One of the fields is of the type "date". Now, at first sight, I find format specifications for dates like "99/99/9999", which should produce a format "DD/MM/YYYY", and "99/99/99", producing "DD/MM/RR", for use in a to_date() call. Note: "RR" specifies a 2 digit year, which will be considered in the range 2000-2049 if it's < 50, and between 1950 and 1999 if >= 50.
Simple enough, a conversion hash
would do... Except: I want to be able to accept other separators than slashes, too. The script should be smart enough to produce the appropriate format with the actual separators. In short, it should produce 'DD-MM-YYYY' out of '99-99-9999', for example.%dateformat = ( '99/99/99' => 'DD/MM/RR', '99/99/9999' => 'DD/MM/YYYY', '9999/99/99' => 'YYYY/MM/DD' );
Your assignment is to write some Perl code which does this conversion. A generic solution, using a data table for the production, is preferred over a hardwired solution, using a code block for each pattern.
I'll post a solution of my own in a follow-up, later.
In reply to Generating a format template for a date by bart
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |