@@ -1711,55 +1711,113 @@ function PageAttributes($data)
17111711 );
17121712}
17131713
1714+ /**
1715+ * Return either the short or long representation of a month in the language for the current admin.
1716+ * Cache the set of month translations to avoid repeating the translations.
1717+ *
1718+ * @param string $month month number 01-12
1719+ * @param bool $short generate short or long representation of the month
1720+ *
1721+ * @return string
1722+ */
17141723function monthName ($ month , $ short = 0 )
17151724{
1716- $ months = array (
1717- '' ,
1718- $ GLOBALS ['I18N ' ]->get ('January ' ),
1719- $ GLOBALS ['I18N ' ]->get ('February ' ),
1720- $ GLOBALS ['I18N ' ]->get ('March ' ),
1721- $ GLOBALS ['I18N ' ]->get ('April ' ),
1722- $ GLOBALS ['I18N ' ]->get ('May ' ),
1723- $ GLOBALS ['I18N ' ]->get ('June ' ),
1724- $ GLOBALS ['I18N ' ]->get ('July ' ),
1725- $ GLOBALS ['I18N ' ]->get ('August ' ),
1726- $ GLOBALS ['I18N ' ]->get ('September ' ),
1727- $ GLOBALS ['I18N ' ]->get ('October ' ),
1728- $ GLOBALS ['I18N ' ]->get ('November ' ),
1729- $ GLOBALS ['I18N ' ]->get ('December ' ),
1730- );
1731- $ shortmonths = array (
1732- '' ,
1733- $ GLOBALS ['I18N ' ]->get ('Jan ' ),
1734- $ GLOBALS ['I18N ' ]->get ('Feb ' ),
1735- $ GLOBALS ['I18N ' ]->get ('Mar ' ),
1736- $ GLOBALS ['I18N ' ]->get ('Apr ' ),
1737- $ GLOBALS ['I18N ' ]->get ('May ' ),
1738- $ GLOBALS ['I18N ' ]->get ('Jun ' ),
1739- $ GLOBALS ['I18N ' ]->get ('Jul ' ),
1740- $ GLOBALS ['I18N ' ]->get ('Aug ' ),
1741- $ GLOBALS ['I18N ' ]->get ('Sep ' ),
1742- $ GLOBALS ['I18N ' ]->get ('Oct ' ),
1743- $ GLOBALS ['I18N ' ]->get ('Nov ' ),
1744- $ GLOBALS ['I18N ' ]->get ('Dec ' ),
1745- );
1725+ static $ shortmonths ;
1726+ static $ months ;
1727+
17461728 if ($ short ) {
1747- return $ shortmonths [intval ($ month )];
1748- } else {
1749- return $ months [intval ($ month )];
1729+ if ($ shortmonths === null ) {
1730+ $ shortmonths = array (
1731+ '' ,
1732+ s ('Jan ' ),
1733+ s ('Feb ' ),
1734+ s ('Mar ' ),
1735+ s ('Apr ' ),
1736+ s ('May ' ),
1737+ s ('Jun ' ),
1738+ s ('Jul ' ),
1739+ s ('Aug ' ),
1740+ s ('Sep ' ),
1741+ s ('Oct ' ),
1742+ s ('Nov ' ),
1743+ s ('Dec ' ),
1744+ );
1745+ }
1746+
1747+ return $ shortmonths [(int ) $ month ];
1748+ }
1749+
1750+ if ($ months === null ) {
1751+ $ months = array (
1752+ '' ,
1753+ s ('January ' ),
1754+ s ('February ' ),
1755+ s ('March ' ),
1756+ s ('April ' ),
1757+ s ('May ' ),
1758+ s ('June ' ),
1759+ s ('July ' ),
1760+ s ('August ' ),
1761+ s ('September ' ),
1762+ s ('October ' ),
1763+ s ('November ' ),
1764+ s ('December ' ),
1765+ );
17501766 }
1767+
1768+ return $ months [(int ) $ month ];
17511769}
17521770
1771+ /**
1772+ * Format a date using a configurable format string.
1773+ * d 2-digit day with leading zero
1774+ * j day without leading zero
1775+ * F long representation of month
1776+ * m 2-digit month with leading zero
1777+ * M short representation of month
1778+ * y 2-digit year
1779+ * Y 4-digit year
1780+ * Optionally force a short representation to be used for the month.
1781+ *
1782+ * @param string $date date as YYYY-MM-DD
1783+ * @param bool $short force short representation of the month
1784+ *
1785+ * @return string
1786+ */
17531787function formatDate ($ date , $ short = 0 )
17541788{
1789+ $ format = getConfig ('date_format ' );
17551790 $ year = substr ($ date , 0 , 4 );
17561791 $ month = substr ($ date , 5 , 2 );
17571792 $ day = substr ($ date , 8 , 2 );
1758- $ day = sprintf ('%d ' , $ day );
1793+ $ specifiers = array (
1794+ 'Y ' => $ year ,
1795+ 'y ' => substr ($ year , 2 , 2 ),
1796+ 'F ' => monthName ($ month , $ short ),
1797+ 'M ' => monthName ($ month , true ),
1798+ 'm ' => $ month ,
1799+ 'd ' => $ day ,
1800+ 'j ' => +$ day ,
1801+ );
1802+ $ result = strtr ($ format , $ specifiers );
1803+
1804+ return $ result ;
1805+ }
1806+
1807+ function formatTime ($ time , $ short = 0 )
1808+ {
1809+ return $ time ;
1810+ }
17591811
1760- if ($ date ) {
1761- return $ day .' ' .monthName (intval ($ month ), $ short ).' ' .$ year ;
1812+ function formatDateTime ($ datetime , $ short = 0 )
1813+ {
1814+ if ($ datetime == '' ) {
1815+ return '' ;
17621816 }
1817+ $ date = substr ($ datetime , 0 , 10 );
1818+ $ time = substr ($ datetime , 11 , 8 );
1819+
1820+ return formatDate ($ date , $ short ).' ' .formatTime ($ time , $ short );
17631821}
17641822
17651823$ oldestpoweredimage = 'iVBORw0KGgoAAAANSUhEUgAAAFgAAAAfCAMAAABUFvrSAAAABGdBTUEAALGPC/xhBQAAAMBQTFRFmQAAZgAAmgICmwUFnAgInQsLnxAQbw4OohYWcBERpBwcpiIiqCcnqiwsfCAgrDAwrjU1rzg4sTs7iTAws0FBtEVFtklJuU9Pu1VVn0pKkEREvltbtFxcwWRkw2trm1ZWrGNjx3V1y3x8zoWFqW5u0I6O15ycuoqK3aysxZqa3rm55s3N8t3d9+zs+fHx5t/f/Pf3/fr6////7+/vz8/PtbW1j4+Pb29vVVVVRkZGKioqExMTDg4OBwcHAwMDAAAAB4LGQwAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxIAAAsSAdLdfvwAAAAHdElNRQfSBAITGhB/UY5ZAAAD2ElEQVR4nI2VC3uiOhCGoVqq9YbcZHGxIoI0SLGhIJdt8///1c4kHnVPhTpPK4TPvEzmpkTvsiK/73vckmAuSdJ93/26G5wEhsQN7uuaVTSrWP1BGT1WtCpgUWUf7FhVX1WWVZ/Hz/Qu6ltoSf8ZLFnxwfKypPBXZ02dsrQss7oovnJ+PZa0au6gHqJFT5KuwDmjGctZzp09lux4pF911RRFTT/x+geU8ifqe2T3pX8MEsM+ioY2BThHyyavm5TWRQ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;
@@ -2017,11 +2075,6 @@ function versionCompare($thisversion, $latestversion)
20172075 return 0 ;
20182076}
20192077
2020- function formatTime ($ time , $ short = 0 )
2021- {
2022- return $ time ;
2023- }
2024-
20252078function cleanArray ($ array )
20262079{
20272080 $ result = array ();
@@ -2038,14 +2091,6 @@ function cleanArray($array)
20382091 return $ result ;
20392092}
20402093
2041- function formatDateTime ($ datetime , $ short = 0 )
2042- {
2043- $ date = substr ($ datetime , 0 , 10 );
2044- $ time = substr ($ datetime , 11 , 8 );
2045-
2046- return formatDate ($ date , $ short ).' ' .formatTime ($ time , $ short );
2047- }
2048-
20492094function cl_processtitle ($ title )
20502095{
20512096 $ title = preg_replace ('/[^\w-]/ ' , '' , $ title );
0 commit comments