Opened 9 years ago

Closed 9 years ago

#815 closed defect (fixed)

date-part for month and day only work in the default formats

Reported by: dstillman Owned by: codec
Priority: major Milestone:
Component: styles Version:
Keywords: Cc: simon

Description


Attachments (1)

cite.js-patch (1.5 KB) - added by codec 9 years ago.
Patch to fix date-part and add ordinal formats

Download all attachments as: .zip

Change History (7)

comment:1 Changed 9 years ago by codec

The date-part uses the wrong variable in cite.js to work out when to use the formatting.
It also doesn't support ordinal formats. These should both be fixed by the attached patch.

e.g.,

<date-part name="month" prefix=" MONTH=" form="long"/>

<date-part name="month" prefix="(" form="short"/>
<date-part name="month" prefix="/" form="numeric"/>
<date-part name="month" prefix="/" suffix=")" form="numeric-leading-zeros" />
<date-part name="day" prefix=" DAY=" form="ordinal" />
<date-part name="day" prefix="/" form="numeric" />
<date-part name="day" prefix="/" form="numeric-leading-zeros" />
<date-part name="other" prefix=" OTHER=" form="long" />
<date-part name="other" prefix=" (" suffix=")" form="short"/>

produces
MONTH=October(October/October/October) DAY=22/22/22

comment:2 follow-up: Changed 9 years ago by dstillman

cite.js isn't my code, but do those ordinal parts need to be localized (Zotero.getString('date.daySuffixes')) or are they just keys?

comment:3 in reply to: ↑ 2 Changed 9 years ago by codec

Replying to dstillman:

cite.js isn't my code, but do those ordinal parts need to be localized (Zotero.getString('date.daySuffixes')) or are they just keys?

I expect they do - I've no idea how complex the ordinal format can get in other languages though - whether you need a full 31 element array or if these is a simpler solution.
Meanwhile the other changes are useful.

comment:4 Changed 9 years ago by dstillman

Well, I suspect date.daySuffixes is wholly inadequate, but for now let's get Zotero.getString('date.daySuffixes'), which will return the locale-specific equivalent of "st, nd, rd, th", split it into four parts, and use those instead of the English strings. From a quick skim of the locales it looks like many of them just use a particular Unicode character for all four, so at least those will work.

comment:5 Changed 9 years ago by codec

OK - the changes seem to be relatively simple - new version about to be added
Produces the following output

YEAR=2007 (07) DAY=1st/1/01 ACCESSED: YEAR=2007 (07) MONTH=October(Oct/9/09) DAY=10th/10/10

Changed 9 years ago by codec

Patch to fix date-part and add ordinal formats

comment:6 Changed 9 years ago by simon

  • Resolution set to fixed
  • Status changed from new to closed

(In [1843]) closes #815, date-part for month and day only work in the default formats (thanks codec)
closes #825, Dates with a month in January can't be displayed

Note: See TracTickets for help on using tickets.