Hi Pablo
Here is a quick solution. However, it not treat the incorrect input
data, ie it requires, however, correct input, otherwise it will collapse ...
Jaroslav Hajtmar
\usemodule[scancsv]
\def\ddmmyyyy#1#2#3{% #1 - date, #2 - old separator, #3 - new separator
\startlua
parsedate=thirddata.scancsv.ParseCSVLine('#1','#2');
day=tonumber(parsedate[1]);
month=tonumber(parsedate[2]);
year=tonumber(parsedate[3]);
if (year<2000) then year=year+2000 end;
tex.print(day..'#3'..month..'#3'..year);
\stoplua
}
\unexpanded\def\lineaction{
\Name\ arrived on \ddmmyyyy{\Date}{/}{.} \\
}
% Name;Date
% ME;11/10/14
% You;05/02/14
% He;15/02/2014
% She;03/03/12
% It;03/03/14
\setheader
\setsep{;}
\setfiletoscan{mail.csv}
\starttext
\filelineaction
\stoptext
Dne 17.12.2014 22:20, Pablo Rodriguez napsal(a):
Dear list,
I have the following sample:
\usemodule[scancsv]
\unexpanded\def\lineaction{
\Name\ arrived on \Date\\
}
\setheader
\setsep{;}
\setfiletoscan{mail.csv}
\starttext
\filelineaction
\stoptext
that reads data from mail.csv:
Name;Date
ME;11/10/14
You;05/02/14
He;15/02/2014
She;03/03/12
It;03/03/14
My question is simple (and not related to CSV data import): how can I
define a command (ConTeXt or Lua) that changes date format from DD/MM/YY
to DD/MM/YYYY when required?
Many thanks for your help,
Pablo
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the
Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
archive : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________