Test if issued date contains month and day

Is it possible to test in CSL (0.8 or 1.0) if a date variable contains all three components - year, month and day?
  • edited March 23, 2010
    No, it isn't, in either CSL version. What is the use case?
  • Based on the University of South Australia style guide, for an electronic publication the date of update should be shown in the bibliography. There is no "updated" field available, so the next best thing would be to show the "issued" date if it contains month and day.
  • Here is an example of the required entry in the reference list for an electronic book:

    Trochim, WM 2000, The research methods knowledge base, 2nd edn, updated 2 August 2000, viewed 14 November 2001, <http://socialresearchmethods.net/kb/index.htm>.
  • Apart from the inability to completely suppress the updated date element if month and day are empty, there is also a problem with using the "issued" year since the current Zotero CSL processor has a side effect of disambiguating the issued year (if the disambiguate-add-year-suffix option is set to true).
  • edited March 23, 2010
    The new CSL processor (coming up in trunk releases in a few months or so) speaks CSL 1.0, in which the year-suffix element can be applied selectively. I've filed a ticket in the CSL tracker on the condition issue. A simple option would be to allow a condition on one or more macros. This would allow you to define a macro containing a date element that renders only the month, or only the day, and if that returns nothing, to know that that element is missing. It's a flexible solution that might be useful elsewhere, but it's just an idea that I've cooked up on my own: we'll have to wait and see what the CSL group makes of it when discussions begin over version 1.1 (CSL 1.0 is now final, and revisions to syntax at this version level are not possible).
  • Maybe worth adding a "last updated" field to certain types which requires a full date? Worth further discussion in any case ...
  • I understand it's not possible to test whether the date field contains the three parts or just one or two.

    When there is no "day" information, since the month is placed just after a period, it has to be "capitalize-first", whereas when there is one, it has to be "lowercase".

    I didn't understand how to use the fbennett's solution.

    Would I dare asking for the coding lines to include in the style so as to obtain the right result? I would be very grateful.
  • edited January 31, 2011
    I also want to edit a style so that it prints a date in the case that the "issued" date has a day and/or month.

    I spent some time looking for a solution. The problem is that the "if" selector can only test if a "variable" is empty or not. That is, "if" cannot test if a "macro" is empty or not.

    What we need is something like this:
    <macro name="day-month">
    <date variable="issued">
    <date-part name="month"/>
    <date-part name="day" prefix=" "/>
    </date>
    </macro>
    <macro name="date-full">
    <choose>
    <if macro="day-month">
    <date variable="issued">
    <date-part name="month" suffix=" "/>
    <date-part name="day" suffix=", "/>
    <date-part name="year" />
    </date>
    </if>
    </choose>
    </macro>


    Unfortunately, this code doesn't work because there's no such option as <if macro="day-month"> ... </if> I can't think of a solution after reading the CSL syntax summary. I think that we'll have to wait for a Zotero upgrade.
  • Yes, there's no way to do this at present.
  • I'm digging this, because google reference it, and I wanted to know if a solution has been done for this? Is it now possible to test for the result of a macro in a if?

    Thanks,
  • There is an extension for doing something similar in CSL-m (an extended version of CSL used by MLZ), but not in official CSL.
  • Thanks a lot fbennett :-)
Sign In or Register to comment.