Date Format

May 03, 2009 20:53

I want to change my date to appear like May 3rd, 2009 at 6:00 pm. I've checked out the tags but I can't seem to get things to work. I already have a themelayer. Would I have to merge something with it? I've posted it below. I have a paid account.

layerinfo "type" = "theme ( Read more... )

date format, solved

Leave a comment

complications_g May 4 2009, 02:18:42 UTC
You need to copy&paste the print_entry(Page p, Entry e, Color bgcolor, Color fgcolor) function from the FS layer source, and then find the # Date, time, subject section.

Find this line: print $e.time->date_format("%%dd%% %%month%% %%yyyy%%"); and change it to whatever format you'd like. Here is a reference list.

Reply

steadyradiance May 4 2009, 02:34:19 UTC
I copy that whole thing and add it to the bottom of the themelayer I have now?

Reply

complications_g May 4 2009, 02:39:23 UTC
Just the print_entry fuction, which goes down until you see the next function, but yep, just add it to the end of your theme layer.

Reply

steadyradiance May 4 2009, 02:42:53 UTC
It may be that it's late or I'm just slow with css today but where is just the print_entry in that link? Which part?

Reply

complications_g May 4 2009, 02:46:26 UTC
Can you use Find in your browser? It'll take you a while if you can't, the layer source is long. Ctrl+F and search for print_entry(Page p, Entry e, Color bgcolor, Color fgcolor.

Reply

steadyradiance May 4 2009, 02:58:23 UTC
I'm an idiot and super confused, so sorry for bothering you with all of this!. I just started using layers. Do I search for everything containing these: Page p, Entry e, Color bgcolor, Color fgcolor?

When does the next function start in there? Sigh.

Reply

complications_g May 4 2009, 03:05:41 UTC
It's ok! The print_entry function is a specific section that you want in your layer, it starts with the line print_entry(Page p, Entry e, Color bgcolor, Color fgcolor and finishes just before function Page::print_entry(Entry e).

Here, I've put it in a layer for you, just copy&paste this into your layer, then change the date format. :)

Reply

steadyradiance May 4 2009, 03:19:28 UTC
I get this error message when I copy & paste that in my themelayer:
S2 Compiler Output at Mon May 4 03:18:52 2009
Error compiling layer:
Compile error: line 232, column 3: Unexpected token parsing statement block
S2::NodeStmtBlock, S2/NodeStmtBlock.pm, 47
S2::NodeFunction, S2/NodeFunction.pm, 104
S2::Layer, S2/Layer.pm, 58
S2::Compiler, S2/Compiler.pm, 27
Context

228: $date = $date + $e.time->date_format("long_day");
229: """
230:

""";
231: print $e.time->date_format("%%month%% %%dayord%% %%yyyy%%");
232: + " at " + $comment.time->time_format("%%h%%:%%min%% %%a%%m"); "$time
233: ";
234: """
235:
""";
236: if ($e.security != "")

Reply

complications_g May 4 2009, 03:23:42 UTC
Hm. Can you link me to your layer please? I'm not sure what the problem is from this. You'll need to add layerinfo source_viewable = 1; just after the layerinfo type/name part, to make it viewable.

Reply

steadyradiance May 4 2009, 03:30:23 UTC
Hm is it this http://www.livejournal.com/customize/advanced/layersource.bml?id=16028821 what you need?

Then I have custom css as well.

Reply

complications_g May 4 2009, 03:39:23 UTC
Huh, did you c&p a whole line from the date format ref link? The comment.time line isn't supposed to be in the layer, you only need to adjust the format in the brackets of this line: print $e.time->date_format("%%dd%% %%month%% %%yyyy%%"); to this:
print $e.time->date_format("%%month%% %%dayord%%, %%yyyy%%");.

Reply

steadyradiance May 4 2009, 03:46:38 UTC
I copy and paste the whole thing you posted here? http://www.livejournal.com/customize/advanced/layersource.bml?id=16032661 And just change the date format?

I tried that and it still won't work. I'm not sure what I'm doing wrong.

Reply

complications_g May 4 2009, 03:49:44 UTC
I tested your layer, with the print_entry function added and it's compiling fine for me. Did you take out layerinfo part at the top from mine? And did you just change the date format in the brackets?

Is it looking like this?

Reply

steadyradiance May 4 2009, 03:56:51 UTC
Yes! You got it to work. Now, before I forget, how would I add the time change to that? So it says something like at 6:00 pm?

Reply

complications_g May 4 2009, 04:01:59 UTC
Find this line: $time = $time + """ @ """; and change the @ to at, or whatever you want. And for the comma, just add it after %%dayord%%.

Reply

steadyradiance May 4 2009, 04:23:45 UTC
Thank you so much for everything! How would I get rid of the 0 in the hour format? I thought I knew but I guess I was wrong. Hahaha.

Reply


Leave a comment

Up