Permalink
Browse files

Added two method (getDate & getTime) as BackendDatagrid-functions, as…

  • Loading branch information...
1 parent c1c0693 commit fe02e69c0a8157aa268de8b176788e3d55c5b0ba @tijsverkoyen tijsverkoyen committed Sep 3, 2011
Showing with 46 additions and 1 deletion.
  1. +2 −1 CHANGELOG.md
  2. +44 −0 default_www/backend/core/engine/datagrid.php
View
@@ -6,7 +6,8 @@ Bugfixes:
Improvements:
-* Core: upgraded jQuery to 1.6.3
+* Core: upgraded jQuery to 1.6.3.
+* Core: added two method (getDate & getTime) as BackendDatagrid-functions, as requested by Frederik (see: http://forum.fork-cms.com/discussions/general/48-shortdate-for-formatting-dat-in-datagrid).
2.6.5 (2011-08-30)
@@ -757,6 +757,28 @@ public static function formatFloat($number, $decimals = 2)
/**
+ * Format a date according the users' settings
+ *
+ * @return string
+ * @param int $timestamp The UNIX-timestamp to format as a human readable date.
+ */
+ public static function getDate($timestamp)
+ {
+ // redefine
+ $timestamp = (int) $timestamp;
+
+ // if invalid timestamp return an empty string
+ if($timestamp <= 0) return '';
+
+ // get user setting for long dates
+ $format = BackendAuthentication::getUser()->getSetting('date_format');
+
+ // format the date according the user his settings
+ return SpoonDate::getDate($format, $timestamp, BL::getInterfaceLanguage());
+ }
+
+
+ /**
* Format a date as a long representation according the users' settings
*
* @return string
@@ -779,6 +801,28 @@ public static function getLongDate($timestamp)
/**
+ * Format a time according the users' settings
+ *
+ * @return string
+ * @param int $timestamp The UNIX-timestamp to format as a human readable time.
+ */
+ public static function getTime($timestamp)
+ {
+ // redefine
+ $timestamp = (int) $timestamp;
+
+ // if invalid timestamp return an empty string
+ if($timestamp <= 0) return '';
+
+ // get user setting for long dates
+ $format = BackendAuthentication::getUser()->getSetting('time_format');
+
+ // format the date according the user his settings
+ return SpoonDate::getDate($format, $timestamp, BL::getInterfaceLanguage());
+ }
+
+
+ /**
* Get time ago as a string for use in a datagrid
*
* @return string

0 comments on commit fe02e69

Please sign in to comment.