Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add implicit docyear and localyear attributes #1372

Closed
mojavelinux opened this issue Jun 17, 2015 · 2 comments
Closed

Add implicit docyear and localyear attributes #1372

mojavelinux opened this issue Jun 17, 2015 · 2 comments
Assignees
Milestone

Comments

@mojavelinux
Copy link
Member

The current year (either in local time or the date the document was modified) is a very typical piece of information needed in a document. Since we already provide *date and *datetime, it makes sense to add *year as well.

Of course, these can be passed into the document explicitly as a workaround.

# localyear
$ asciidoctor -a localyear=`date +%G` file.adoc
# docyear
$ asciidoctor -a docyear=`stat -c %y file.adoc | cut -d- -f1` file.adoc
@mojavelinux mojavelinux added this to the v1.5.4 milestone Jun 17, 2015
@mojavelinux mojavelinux changed the title Add docyear and localyear attributes Add implicit docyear and localyear attributes Jun 17, 2015
@mojavelinux mojavelinux modified the milestones: v1.5.4, v1.5.5 Dec 21, 2015
@mojavelinux mojavelinux modified the milestones: v1.5.5, v1.5.6 Oct 3, 2016
mojavelinux added a commit to mojavelinux/asciidoctor that referenced this issue Jan 5, 2017
mojavelinux added a commit to mojavelinux/asciidoctor that referenced this issue Jan 5, 2017
mojavelinux added a commit to mojavelinux/asciidoctor that referenced this issue Jan 5, 2017
@mojavelinux
Copy link
Member Author

mojavelinux commented Jan 5, 2017

The question to answer is, should we create the docyear / localyear based off of the docdate / localdate attributes, or should we calculate them independently and require them to be set if you are setting the docdate or localdate explicitly?

The problem with basing the values off of docdate and localdate is that there is no guarantee that those values are formatted any particular way.

As it stands now (in PR #1988), the code calculates docyear and localyear the same way it calculates docdate and localdate, assuming the use of built-in values. If docdate or localdate is overrridden (from the API or CLI), those values do not currently affect docyear or localyear. Instead, docyear and localyear have to be set independently.

@mojavelinux
Copy link
Member Author

I decided to go ahead and parse docdate and/or localdate if they are specified and in the expected format of %Y-%m-%d. That should minimize confusion.

Therefore, it's enough to just use:

-a docdate=2016-11-10

But you can also override the docyear if you want.

ggrossetie pushed a commit to ggrossetie/asciidoctor that referenced this issue Mar 11, 2017
- derive docyear from docdate if specified
- derive localyear from localdate if specified
- add docyear and localyear to tests
- optimize code
@mojavelinux mojavelinux removed the wip label Jul 2, 2017
@mojavelinux mojavelinux self-assigned this Jul 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant