New Date/Time tags in development

 
From: "Justin J" <justin@PROTECTED>
Date: October 17th 2011

Hey everyone,

I'm working on putting a little more flexibility in the types of dates you can put in your email templates Currently, you only have one (undocumented) choice:

<!-- tmpl_var date --> 

which isn't very useful

I've added a whole slew of new ones, included support for, "strftime", which should allow you to print whatever you'd like You can see my progress at:

https://github
com/justingit/dada-mail/tree/features-date_tags

I don't have any tests written up, yet

Below is the current addition to the email syntax docs:

Date-related tags Dada Mail includes a few tags to dynamically put the current data in your email message They'll take on the form:

        <!-- tmpl_var date
x -->

Where, "x" is a specific variable, which we'll explain below


For example, if the current date is: Monday, October 15th, 2011 at 2:55
PM, the following tags would return:

*   <!-- tmpl_var date
month -->

    Will print out the month
 For "October", this would print out,

            10

*   <!-- tmpl_var date
padded_month -->

    Will return the month, padded with a, "0" if the value is less than
    "0"
 For October, it would look the same as, "date
month":

            10

    But, for something like January, it'll look like this:

            01

*   <!-- tmpl_var date
named_month -->

    Will print out the name of the month
 For October, this would print
    out,

            October

*   <!-- tmpl_var date
abbr_named_month -->

    Will print out the name of the month, in an abbreviated form
 For
    October, this would print out,

            Oct

*   <!-- tmpl_var date
day -->

    Will print the day of the month
 For, "October 17th", this would
    print out:

            17

*   <!-- tmpl_var date
nth_day -->

    Will print the day of the month, with the correct ordinal suffix

    For, "October 17th", this would print out:

            17th

*   <!-- tmpl_var date
padded_day -->

    Will print the day of the month, padded for values less than, "10"

    For the 17th, this would print out,

            17

    But for October 1st, this would print out:

            01

*   <!-- tmpl_var date
day_of_the_week -->

    Will print out the day of the week
 For, "Monday, October 15th",
    this would print out,

            Monday

*   <!-- tmpl_var date
abbr_day_of_the_week -->

    Will print out the day of the week, in an abbreviated form
 For,
    "Monday", this would print out,

            Mon

*   <!-- tmpl_var date
year -->

    Will print out the current year
 For example:

            2011

*   <!-- tmpl_var date
abbr_year -->

    Will print out the abbreviated year (last two digits)
 For example
    2011, will be printed out as:

            11

*   <!-- tmpl_var date
time -->

    Will print out the, "Unix Time" For example:

            1318884939

*   <!-- tmpl_var date
localtime -->

    Will print out the current date and time in a format like this:

            Mon Oct 17 14:55:39 2011

    Will print out the time (hour:minute:second) in 24 hour time
 So, if
    it's 4:33 PM, this will be printed out as:

            16:33:25

You can then use these different tags to create different date formats

Little endian forms * 18 October 2011

            <!-- tmpl_var date
day --> <!-- tmpl_var date
named_month --> <!-- tmpl_var date
year -->

*   10/18/2011

            <!-- tmpl_var date
day -->/<!-- tmpl_var date
month -->/<!-- tmpl_var date
year -->

Big endian forms * 2011-10-17 (ISO 8601 international standard)

            <!-- tmpl_var date
year -->-<!-- tmpl_var date
padded_month -->-<!-- tmpl_var date
padded_day -->

*   2011-Oct-17, Monday

            <!-- tmpl_var date
year -->-<!-- tmpl_var date
abbr_named_month -->-<!-- tmpl_var date
day -->, <!-- tmpl_var date
day_of_the_week -->

Middle endian forms * Monday, October 17, 2011

            <!-- tmpl_var date
day_of_the_week -->, <!-- tmpl_var date
named_month --> <!-- tmpl_var date
day -->, <!-- tmpl_var date
year -->

*   11/09/03

            <!-- tmpl_var date
padded_month -->/<!-- tmpl_var date
padded_day -->/<!-- tmpl_var date
abbr_year -->

Flexible Date and Time formats If the included simple date tags are not enough, Dada Mail has support for "strftime" formatting using the CPAN Module, "Time::Piece"

The formatting is documented at:

<http://www
unix
com/man-page/FreeBSD/3/strftime/>

If you're familiar with PHP's time formatting:

<http://php
net/manual/en/function
strftime
php>

it's the same thing


To use this in Dada Mail's templating syntax, use the "<!-- tmpl_time_piece --> tag, like this: "

        <!-- tmpl_time_piece %a, %d %b %Y -->

This will print out,

        Mon, 17 Oct 2011
  • This mailing list is a public mailing list - anyone may join or leave, at any time.
  • This mailing list is a group discussion list (unmoderated)
  • Start a new thread, email: dadadev@dadamailproject.com

This is the developer discussion mailing list for Dada Mail.

If you are just looking for support Dada Mail, consult the message boards at:

https://forum.dadamailproject.com

Documentation for Dada Mail:

https://dadamailproject.com/d

Specifically, see the Error FAQ:

https://dadamailproject.com/d/FAQ-errors.pod.html

To post to this list, send a message to:

mailto:dadadev@dadamailproject.com

All subscribers of this list may post to the list itself.

Topics that are welcome:

  • Constructive critiques on the program (I like, "x", but, "y" needs some work - here's an idea on how to make this better...)
  • Bug/Error reports
  • Bug fixes
  • Request For Comments on any changes to the program
  • Help customizing Dada Mail for your own needs
  • Patches
  • Language Translations
  • Support Documentation/Doc editing, FAQ's, etc.
  • Discussion of any changes that you would like to be committed to the next version of Dada Mail -

Dada Mail is on Github:

https://github.com/justingit/dada-mail/

If you would like to fork, branch, send over PRs, open up issues, etc.

Privacy Policy:

This Privacy Policy is for this mailing list, and this mailing list only.

Email addresses collection through this mailing list are used explicitly to work within this email discussion list.

We only collect email addresses through our Closed-Loop Opt-In system.

We don't use your email address for any other purpose.

We won't be sharing your email address with any other entity.

Unsubscription can be done at any time. Please contact us at: justin@dadamailproject.com for any help regarding your subscription, including removal from the mailing list.

All mailing list messages sent from us will include a subscription removal link, which will allow you to remove yourself from this mailing list automatically, and permanently.

All consent to use your email address for any other purpose stated at the time of the mailing list subscription will also be revoked upon mailing list removal.