{assign var=class value="cf_datepicker"}
{if $display_format|strpos:"datetime" === 0}
  {assign var=class value="cf_datetimepicker"}
{/if}

{assign var="val" value=""}
{if $VALUE}
  {assign var=tzo value=""}
  {if $apply_timezone_offset == "yes"}
    {assign var=tzo value=$ACCOUNT_INFO.timezone_offset}
  {/if}
  {if $display_format == "yy-mm-dd"}
    {assign var=val value=$VALUE|custom_format_date:$tzo:"Y-m-d"}
  {elseif $display_format == "dd/mm/yy"}
    {assign var=val value=$VALUE|custom_format_date:$tzo:"d/m/Y"}
  {elseif $display_format == "mm/dd/yy"}
    {assign var=val value=$VALUE|custom_format_date:$tzo:"m/d/Y"}
  {elseif $display_format == "M d, yy"}
    {assign var=val value=$VALUE|custom_format_date:$tzo:"M j, Y"}
  {elseif $display_format == "MM d, yy"}
    {assign var=val value=$VALUE|custom_format_date:$tzo:"F j, Y"}
  {elseif $display_format == "D M d, yy"}
    {assign var=val value=$VALUE|custom_format_date:$tzo:"D M j, Y"}
  {elseif $display_format == "DD, MM d, yy"}
    {assign var=val value=$VALUE|custom_format_date:$tzo:"l M j, Y"}
  {elseif $display_format == "dd. mm. yy"}
    {assign var=val value=$VALUE|custom_format_date:$tzo:"d. m. Y"}
  {elseif $display_format == "datetime:dd/mm/yy|h:mm TT|ampm`true"}
    {assign var=val value=$VALUE|custom_format_date:$tzo:"d/m/Y g:i A"}
  {elseif $display_format == "datetime:mm/dd/yy|h:mm TT|ampm`true"}
    {assign var=val value=$VALUE|custom_format_date:$tzo:"m/d/Y g:i A"}
  {elseif $display_format == "datetime:yy-mm-dd|h:mm TT|ampm`true"}
    {assign var=val value=$VALUE|custom_format_date:$tzo:"Y-m-d g:i A"}
  {elseif $display_format == "datetime:yy-mm-dd|hh:mm"}
    {assign var=val value=$VALUE|custom_format_date:$tzo:"Y-m-d H:i"}
  {elseif $display_format == "datetime:yy-mm-dd|hh:mm:ss|showSecond`true"}
    {assign var=val value=$VALUE|custom_format_date:$tzo:"Y-m-d H:i:s"}
  {elseif $display_format == "datetime:dd. mm. yy|hh:mm"}
    {assign var=val value=$VALUE|custom_format_date:$tzo:"d. m. Y H:i"}
  {/if}
{/if}

<div class="cf_date_group">
  <input type="input" name="{$NAME}" id="{$NAME}_id" class="cf_datefield {$class}"
    value="{$val}" /><img class="ui-datepicker-trigger" src="{$g_root_url}/global/images/calendar.png" 
    id="{$NAME}_icon_id" />
  <input type="hidden" id="{$NAME}_format" value="{$display_format}" />
  {if $comments}
    <div class="cf_field_comments">{$comments}</div>
  {/if}
</div>