Hello,

At the moment, convert data can convert a date to a string, but the output can only be a Linux timestamp.
It would be useful to be able to provide a format, and even a timezone, to get a usable string (to put in a mail, display to a user...).
Patch will follow.

David

Files: 
CommentFileSizeAuthor
#6 1898828-6-rules-convert-date2string.patch14.08 KBDavid Stosik
PASSED: [[SimpleTest]]: [MySQL] 333 pass(es).
[ View ]
#5 1898828-5-rules-convert-date2string.patch14.09 KBDavid Stosik
PASSED: [[SimpleTest]]: [MySQL] 329 pass(es).
[ View ]
#3 1898828-3-rules-convert-date2string.patch14.08 KBDavid Stosik
PASSED: [[SimpleTest]]: [MySQL] 327 pass(es).
[ View ]
#1 1898828-1-rules-convert-date2string.patch13.85 KBDavid Stosik
PASSED: [[SimpleTest]]: [MySQL] 327 pass(es).
[ View ]

Comments

Status:Active» Needs review
StatusFileSize
new13.85 KB
PASSED: [[SimpleTest]]: [MySQL] 327 pass(es).
[ View ]

Here is the patch.
Feel free to test and give me a feedback.
David

Status:Needs review» Needs work

My code breaks other actions, such as "Add a variable", but I don't know why yet.
Any help is welcome!

Status:Needs work» Needs review
StatusFileSize
new14.08 KB
PASSED: [[SimpleTest]]: [MySQL] 327 pass(es).
[ View ]

Here is a better patch, that does not seem to break anything.

David

Patch #3 works for me, and handy workaround for formatting dates as strings in rules. Thanks!

StatusFileSize
new14.09 KB
PASSED: [[SimpleTest]]: [MySQL] 329 pass(es).
[ View ]

Here is a new version working on Rules-2.x branch, with a small fix concerning date custom format.

StatusFileSize
new14.08 KB
PASSED: [[SimpleTest]]: [MySQL] 333 pass(es).
[ View ]

Actually, previous patch was just a reroll. This one here fixes the custom date format field.

Regards,
David

David, I tried your patch #6 - it is exactly what I needed and works fine.
I needed to set an ISO Date value for a text field (to hand the string over to Facebook to post an event on a Facebook page via module fb_autopost)

Great job

Thanks

Status:Needs review» Reviewed & tested by the community

Title:Convert date to string using a date format (and a timezone)Add actions to format dates and durations
Status:Reviewed & tested by the community» Needs work

Thank you for the patch.

However, I'm not so happy with the increased complexity it adds to the data type conversion action. Also, I don't think formatting a date is something that should be handled in a date conversion action - it's way more than just converting the data type, it's formatting. So this qualifies as a separate action.

Note, that we have intervals as separate data types also ("duration"), so I think we shouldn't bake formatting durations into the same action either but use another one. I don't know whether core has any built-in duration formats, I guess not - in which case we'd have to roll our own as the patch does.

Issue tags:+Need tests

oh, and I forgot - we'll need test coverage for that.