From 0dad2954177abf49f8e84bbbe3f78a67fc445048 Mon Sep 17 00:00:00 2001
From: Klaus Purer <klaus.purer@gmail.com>
Date: Thu, 3 Mar 2011 11:41:10 +0100
Subject: [PATCH] Added a timestamp string conversion action

---
 .../transformers_actions.rules.inc                 |   26 ++++++++++++++++++++
 1 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/transformers_actions/transformers_actions.rules.inc b/transformers_actions/transformers_actions.rules.inc
index 08d8c5d..8944125 100644
--- a/transformers_actions/transformers_actions.rules.inc
+++ b/transformers_actions/transformers_actions.rules.inc
@@ -214,6 +214,24 @@ function transformers_actions_rules_action_info() {
       'base' => 'transformers_actions_annotate_xml',
       'group' => t('Transformers'),
     ),
+    'transform_timestamp' => array(
+      'label' => t('Transform a timestamp string'),
+      'parameter' => array(
+        'text' => array(
+          'type' => 'text',
+          'label' => t('Input string'),
+          'description' => t('The format of the string must be acceptable for the PHP !strtotime function.', array('!strtotime' => l('strtotime()', 'http://php.net/strtotime'))),
+        ),
+      ),
+      'provides' => array(
+        'timestamp' => array(
+          'type' => 'date',
+          'label' => t('Timestamp'),
+        )
+      ),
+      'base' => 'transformers_actions_timestamp',
+      'group' => t('Transformers'),
+    ),
   );
 }
 
@@ -336,3 +354,11 @@ function transformers_actions_annotate_xml_process(RulesPlugin $element) {
   $element_info['provides']['annotated_xml_element']['property info'] = $property_info;
   $element->alterInfo($element_info);
 }
+
+/**
+ * Action: Transform timestamp string.
+ */
+function transformers_actions_timestamp($string) {
+  $time = strtotime($string);
+  return array('timestamp' => $time);
+}
-- 
1.7.1

