Jul 11, 2006 16:12
Is there any way to tell, programmatically, what Date or DateTime "today" or "now" are from within an S2 layer's code? I would dearly love to style today's entries slightly differently, but there doesn't seem to be anything in Core that returns a current timestamp.
How does one go about submitting feature requests for S2 Core, anyway?
Leave a comment
DateTime time A DateTime object filled with the time (GMT) when the page was created. (Read-only)
which you could then format in such a way as to compare the date with the date of the entry, or whatever. (Page-created time being 'today', more or less.)
Reply
The one unfortunate wrinkle, of course, is that the Page time is in GMT, but Entry times are user-specified and are generally in their own local time. Alas, alack. But this is darn close, thanks!
Reply
Reply
That's 'cause it only works with a Date class object -- both Date and DateTime have the compare function, but it only takes Date as an argument -- and both the Page::time and Entry::time are DateTime objects, not Dates.
(You could also do it with CSS instead of string comparison; that is, have the entry container HTML include class="$e.time->date_format("%%d%%%%m%%%%yy%%")" (er, you'd have to calculate the date format thingum outside of the string, and then do class="$date"), and have the page-generated CSS include the special instructions for things of class $p.time->date_format("%%d%%%%m%%%%yy%%") (again generating it outside the string)... but that's kind of silly when you can just compare the two formatted $.times. *grin*)
Reply
I think S2 automatically handles it even when you're passing as a parameter (example is Page p which is usually passed to print_entry, or what Bloggish does with EntryLite/Entry/Comment. Um, what does Bloggish do? No need to answer that XP)
Off on a tangent there...
Ah, yes, I did try casting it to a Date using the as keyword, and it worked, but the compiler still complained even when both the caller and the parameter were of type Date (was reflected in the error message ( ... )
Reply
Leave a comment