Editing
Project:Village pump (technical)
(section)
From Thetacola Wiki
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== How can a template calculate the diff between year-and-month dates? == I'd like a citation template to calculate how old a publication is, because if it's > 3yrs, <code>doi-access</code> should be set to 'free'. Publication is quarterly, and the publisher's dates in their DB are YYYY/MM, so it would be nice if the notice for free access turned on the month. But I can't just subtract the <code>date</code> param from a truncated CURRENTTIMESTAMP, because neither is decimal. I assume this has been done before, just don't know where to look. [[User:Kwamikagami|β kwami]] ([[User talk:Kwamikagami|talk]]) 23:37, 9 August 2022 (UTC) :You could probably do the calculation using [[Julian day]]s. Or, something like the following usage of {{tl|time interval}} might help. <code>show=d</code> gives a number of days and <code>disp=raw</code> gives just the number. You could use <code>show=y</code> for years but I would need a fair bit of time to experiment or recall how it rounds. :*<code><nowiki>{{time interval|1 Jan 2001|March 4, 2002|disp=raw|show=d}}</nowiki></code> β {{time interval|1 Jan 2001|March 4, 2002|disp=raw|show=d}} :[[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 00:00, 10 August 2022 (UTC) ::Thanks! I think I can take it from there. If I get stuck I'll ping you. [[User:Kwamikagami|β kwami]] ([[User talk:Kwamikagami|talk]]) 01:13, 10 August 2022 (UTC) That works! If I plug in 2019-08, it displays as free access; if 2019-09, it doesn't. [[User:Kwamikagami|β kwami]] ([[User talk:Kwamikagami|talk]]) 01:27, 10 August 2022 (UTC) :{{ping|Kwamikagami}} I had a look at [[Template:Cite JIPA]]. The date/age modules are complex and not fully documented and I have forgotten exactly what <code>partial=on</code> does as far as date differences go, so I'll just mention that using <code>partial=on</code> makes {{tl|time interval}} accept incomplete dates such as "2001" or "March 2001". In a quick test, I couldn't make sense of the resulting number and I can't take the time at the moment to dive in deeper. Ask me in a couple of weeks if you want that investigated (I should do it!). However, what I am confident about is that omitting a date means the current date is used. For example, these give the same result and this may be of use: :*<code><nowiki>{{time interval|2020-8-10|{{date}}|disp=raw|show=d}}</nowiki></code> β {{time interval|2020-8-10|{{date}}|disp=raw|show=d}} :*<code><nowiki>{{time interval|2020-8-10||disp=raw|show=d}}</nowiki></code> β {{time interval|2020-8-10||disp=raw|show=d}} :[[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 07:32, 10 August 2022 (UTC) ::Thanks! That simplifies things quite a bit. I'll play around with it tomorrow. [[User:Kwamikagami|β kwami]] ([[User talk:Kwamikagami|talk]]) 08:12, 10 August 2022 (UTC) :::That allowed me to cut a fair amount of clutter in the code and end up being more forgiving of date formats. Enough that I could reduce the documentation. [[User:Kwamikagami|β kwami]] ([[User talk:Kwamikagami|talk]]) 09:23, 10 August 2022 (UTC)
Summary:
Please note that all contributions to Thetacola Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Project:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Page actions
Project page
Discussion
Read
Edit source
History
Page actions
Project page
Discussion
More
Tools
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Search
Tools
What links here
Related changes
Special pages
Page information