On 7/17/2012 5:16 PM, s novell wrote:
>
> Hello All,
> I have a date attribute coming from csv and it could be any of the
> following format...
>
> 01/01/2012
> 1/01/2012
> 01/1/2012
> 1/1/2012
>
> and I wanted to normalize it to 01/01/2012 (dd/mm/yyyy) format using
> regex or any other way. Could someone help me with it.


If your concern is the 01 vs 1, then I am pretty sure, that Convert time
the token would not differentiate...

Test the data through this basic policy and see if your combinations work:

I fed in this doc to Simulator:

<?xml version="1.0" encoding="UTF-8"?><nds dtdversion="4.0"
ndsversion="8.x">
<source>
<product version="?.?.?.?">DirXML</product>
<contact>Novell, Inc.</contact>
</source>
<input>
<add class-name="User">
<add-attr attr-name="SomeDateFormat">
<value type="string">01/01/2012</value>
</add-attr>
</add>
</input>
</nds>

Into this rule:

<rule>
<description>Handle 1 or 01 in dates</description>
<comment xml:space="preserve">Testing using Convert Time</comment>
<comment name="author" xml:space="preserve">Geoffrey Carman</comment>
<comment name="version" xml:space="preserve">1</comment>
<comment name="lastchanged" xml:space="preserve">Jul 17, 2012</comment>
<conditions>
<and>
<if-op-attr name="SomeDateFormat" op="changing"/>
</and>
</conditions>
<actions>
<do-reformat-op-attr name="SomeDateFormat">
<arg-value type="string">
<token-convert-time dest-format="M/d/yyyy" src-format="MM/dd/yyyy">
<token-local-variable name="current-value"/>
</token-convert-time>
</arg-value>
</do-reformat-op-attr>
</actions>
</rule>

And got this output:

<nds dtdversion="4.0" ndsversion="8.x">
<source>
<product version="?.?.?.?">DirXML</product>
<contact>Novell, Inc.</contact>
</source>
<input>
<add class-name="User">
<add-attr attr-name="SomeDateFormat">
<value type="string">1/1/2012</value>
</add-attr>
</add>
</input>
</nds>


which seems like what you want?