Skip to content

Instantly share code, notes, and snippets.

@CaMer0n
Created March 5, 2013 21:56
Show Gist options
  • Save CaMer0n/5094691 to your computer and use it in GitHub Desktop.
Save CaMer0n/5094691 to your computer and use it in GitHub Desktop.
jQuery UI Datepicker Issue / Bug Problem - testing code.
// From the jQuery API docs.
print_a("
d - day of month (no leading zero)
dd - day of month (two digit)
o - day of the year (no leading zeros)
oo - day of the year (three digit)
D - day name short
DD - day name long
m - month of year (no leading zero)
mm - month of year (two digit)
M - month name short
MM - month name long
y - year (two digit)
yy - year (four digit)
@ - Unix timestamp (ms since 01/01/1970)
! - Windows ticks (100ns since 01/01/0001)
'...' - literal text
'' - single quote
anything else - literal text
");
$dateTest = "21 April 14 ";
$def = strtotime($dateTest);
$inputdate = array( // TODO add more formats
"%A, %d %B, %Y" => strftime("%A, %d %B, %Y",$def),
"%A, %d %b, %Y" => strftime("%A, %d %b, %Y",$def),
"%a, %d %B, %Y" => strftime("%a, %d %B, %Y",$def),
"%a, %d %b, %Y" => strftime("%a, %d %b, %Y",$def),
"%A, %B %d, %Y" => strftime("%A, %B %d, %Y",$def),
"%A, %b %d, %Y" => strftime("%A, %b %d, %Y",$def),
"%A, %b %d, %y" => strftime("%A, %b %d, %y",$def),
"%B %d, %Y" => strftime("%B %d, %Y",$def),
"%b %d, %Y" => strftime("%b %d, %Y",$def),
"%b %d, %y" => strftime("%b %d, %y",$def),
"%d %B, %Y" => strftime("%d %B, %Y",$def),
"%d %b, %Y" => strftime("%d %b, %Y",$def),
"%d %b, %y" => strftime("%d %b, %y",$def),
"%Y-%m-%d" => strftime("%Y-%m-%d",$def),
"%d-%m-%Y" => strftime("%d-%m-%Y",$def),
"%m/%d/%Y" => strftime("%m/%d/%Y",$def)
);
$dt = e107::getDate();
$text = "<table class='table'>";
$text .= "<thead><tr>";
$text .= "<th>Legacy Format</th><th>New Format</th><th>Value</th><th>Rendered Value</th>";
$text .= "</tr></thead>";
$frm = e107::getForm();
$c=0;
foreach($inputdate as $format=>$val)
{
$newformat = $dt->toMask($format);
$converted = $frm->datepicker('myname_'.$c,$def,'dateformat='.$newformat);
$text .= "<tr>";
$text .= "<td>".$format."</td><td>{$newformat}</td><td>{$val}</td><td>{$converted}</td>";
$text .= "</tr>";
$c++;
}
$text .= "</table>";
$ns->tablerender($dateTest." (".$def.")" ,$text);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment