Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2012-03-08 15:11:30

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,448
Website GitHub

Re: good article on date formatting

candyman wrote:

I expect 8 months ago (or , better, “8 mesi fa”)

Re-check the start of the article, upon which the format="human" is based:

If the event happened this hour: 18 minutes ago
If it happened today: 3:49 pm
If it happened in the last two days: Wed 1:26 pm
If it happened this week: Thursday 8 am
If it was this month: Feb 27th
If it was this year: Jan 19th
If it was before: Jun 6th 2010

Thus if it occurred 8 months ago, it’s ‘last year’ which means it’s using the last format in the list. If you want it to use ‘n’ months ago you’re out of luck, sorry. Txp will only offer N days ago (I think) if you change the archive date format in prefs, but I think that’s it.

I could see if there’s a way to expose the number of days, months and years ago as a special code in the format string. Currently there’s only one special code SMD_ORDINAL which allows you to display the English ‘rd’, ‘th’ ‘st’ etc in your format attribute.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#14 2012-03-08 15:20:36

candyman
Member
From: Italy
Registered: 2006-08-08
Posts: 684

Re: good article on date formatting

I’ve understood, thanks.

I hope that in the next release you’ll be able to specify the formats for each breakpoint and, maybe, to find a solution for the ordinals localization (more difficult to achieve, I think).

Anyway

If it was this month: Feb 27th
If it was this year: Jan 19th

aren’t too similar?

For “If it was this year” I’d specify the number of months (one month ago, two months ago… eleven months ago) and, at the end, “last year”, “two years ago” and more. But, probably, in English it sounds better in your way. Just my thought, thanks again.

Last edited by candyman (2012-03-08 15:36:43)

Offline

#15 2012-03-08 17:17:10

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,448
Website GitHub

Re: good article on date formatting

candyman wrote:

I hope that in the next release you’ll be able to specify the formats for each breakpoint

Haha! So do I.

find a solution for the ordinals localization

Unfortunately, if PHP doesn’t support it, I can’t. Would love to find out how to do it though. I mean, in French I think ‘er’ is the only one used (correct me if I’m wrong but I’m sure I’ve seen 3{er} in use). I don’t know about other languages but I suppose I could add an attribute to let you specify them like this:

ordinals="st,nd,rd,th"

So in French you’d do:

ordinals="er"

(?) But in Italian for example it gets more complicated because it differs based on gender doesn’t it? But I guess if the ‘thing’‘ you are referring to is always a date then it’s only going to be of one gender… umm right? Or are the different months of different genders? If anybody has any ideas on this then please let me know.

If it was this month: Feb 27th / If it was this year: Jan 19th

Yes I spotted that they were the same so I just opted for one breakpoint.

For “If it was this year” I’d specify the number of months (one month ago, two months ago… eleven months ago) and, at the end, “last year”, “two years ago” and more.

That could be a tall order given the language strings involved but I’ll see if I can rustle something up. Won’t be immediately though.. got another plugin I’m hammering away at now and it’s BIG.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#16 2012-03-08 20:32:52

candyman
Member
From: Italy
Registered: 2006-08-08
Posts: 684

Re: good article on date formatting

Gender it’s not a problem: in Italian are used Cardinal numbers to specify the day of the month, with the exception of the first day which is always ordinal (primo).

15th September = 15 settembre
1st january = primo gennaio

I think this page may you help a lot (when you will have time for smd_time ;) at least for the Italian localization.

It will be interesting the possibility to add some customized dates…

15th August = Ferragosto
25th December = Natale (Xmas)

… and so on, but I know you have a BIG project yet… ;)

Last edited by candyman (2012-03-08 20:42:22)

Offline

Board footer

Powered by FluxBB