Difference between revisions of "Hierarchy: Print Time Functions"

From Dreamwidth Notes
Jump to: navigation, search
(Added text.)
m (typo, facepalm)
 
(8 intermediate revisions by 2 users not shown)
Line 1: Line 1:
This is an extension of [[Hierarchy]], where you are introduced into the wild and crazy world of layouts and view functions.  If you haven't been there yet, start there or this might not make much sense.
+
This is an extension of [[Hierarchy]], where you are introduced into the wild and baffling world of layouts and view functions.  If you haven't been there yet, start there or this might not make much sense.
  
 
==Purpose==
 
==Purpose==
  
 
Each of these pages is specifically designed to follow a function from how it appears in a view page down to its root functions, variables, and properties.  Basically, by the end, you should understand in theory why a function exists and how its put together.  Eventually, you will also be able to understand how to alter, change, and even override the functions and both where their variables are stored and why they're there.
 
Each of these pages is specifically designed to follow a function from how it appears in a view page down to its root functions, variables, and properties.  Basically, by the end, you should understand in theory why a function exists and how its put together.  Eventually, you will also be able to understand how to alter, change, and even override the functions and both where their variables are stored and why they're there.
 +
 +
<hr>
  
 
==In the Beginning==
 
==In the Beginning==
  
 
Add text.
 
Add text.
 +
 +
<hr>
  
 
==Function: print_time==
 
==Function: print_time==
 +
 +
Add text.
 +
 +
<hr>
  
 
===class Entrylite===
 
===class Entrylite===
Line 41: Line 49:
 
}
 
}
 
</source>
 
</source>
:# Let the real function decide on some nice defaults
+
:Let the real function decide on some nice defaults
  
 
 
Line 82: Line 90:
 
</source>
 
</source>
 
:Returns time formatted as indicated by \$fmt, or normal if blank.  /// SeeAlso: siteapi.core1.dateformats
 
:Returns time formatted as indicated by \$fmt, or normal if blank.  /// SeeAlso: siteapi.core1.dateformats
 
 
 
 
 
  
 +
<hr>
  
 
===class Comment===
 
===class Comment===
  
 +
Function
  
 +
<source lang="perl">
 +
function Comment::print_time (string datefmt, string timefmt, bool edittime);
 +
</source>
 +
:Same as EntryLite::print_time, except can pass in if we want the edit time or not.
 +
 +
Stucture
 +
 +
<source lang="perl">
 +
function Comment::print_time (string datefmt, string timefmt)
 +
{
 +
    $this->print_time($datefmt, $timefmt, false);
 +
}
 +
</source>
 +
 +
<hr>
  
 
===class Page===
 
===class Page===
  
 +
Function
 +
 +
<source lang="perl">
 +
function Page::print_time();
 +
</source>
 +
:Print the time when the page was created.
 +
 +
Structure:
 +
 +
<source lang="perl">
 +
function Page::print_time()
 +
{
 +
    $this->print_time("","");
 +
}
 +
</source>
 +
           
 +
<source lang="perl">
 +
function Page::print_time(string datefmt, string timefmt)
 +
{
 +
    if ($datefmt == ""){$datefmt = "med";}
 +
    if ($timefmt == ""){$timefmt = "short";}
 +
    var string ret;
 +
    if ($datefmt != "none") { $ret = $ret + $this.local_time->date_format($datefmt); }
 +
    if ($datefmt != "none" and $timefmt != "none") { $ret = $ret + " "; }
 +
    if ($timefmt != "none") { $ret = $ret + $this.local_time->time_format($timefmt); }
 +
    print safe """<span id="load-time">$*text_generated_on $ret</span>""";
 +
}
 +
</source>
 +
 +
<hr>
  
 
===Associated Properties===
 
===Associated Properties===
 +
 +
Associated Properties
 +
 +
<source lang="perl">
 +
property string[] entry_datetime_format_group
 +
{
 +
  des = "Entry date/time format";
 +
grouptype = "datetime";
 +
}
 +
</source>
 +
 +
<source lang="perl">
 +
property string entry_date_format
 +
{
 +
    des = "Entry date format";
 +
    values = "short|2/5/80|med|Feb. 5th, 1980|med_day|Tue, Feb. 5th, 1980|long|February 5th, 1980|long_day|Tuesday, February 5th, 1980";
 +
    grouped = 1;
 +
}
 +
</source>
 +
 +
<source lang="perl">
 +
property string entry_time_format
 +
{
 +
    des = "Entry time format.";
 +
    values = "short|12:34am";
 +
    grouped = 1;
 +
}
 +
</source>
 +
 +
<source lang="perl">
 +
property string[] comment_datetime_format_group
 +
{
 +
    des = "Comment date/time format";
 +
    grouptype = "datetime";
 +
}
 +
</source>
 +
 +
<source lang="perl">
 +
property string comment_date_format
 +
{
 +
    des = "Comment date format";
 +
    values = "short|2/5/80|med|Feb. 5th, 1980|med_day|Tue, Feb. 5th, 1980|long|February 5th, 1980|long_day|Tuesday, February 5th, 1980";
 +
    grouped = 1;
 +
}
 +
</source>
 +
 +
<source lang="perl">
 +
property string comment_time_format
 +
{
 +
    des = "Comment time format.";
 +
    values = "short|12:34am";
 +
    grouped = 1;
 +
}
 +
</source>
 +
 +
<source lang="perl">
 +
set entry_datetime_format_group = ["entry_date_format", "entry_time_format"];
 +
set entry_date_format = "short";
 +
set entry_time_format = "short";
 +
set comment_datetime_format_group = ["comment_date_format", "comment_time_format"];
 +
set comment_date_format = "short";
 +
set comment_time_format = "short";
 +
</source>
 +
 +
<hr>
 +
 +
==Conclusion==
 +
 +
Add text.
 +
 +
 +
[[Category: Styles]]
 +
[[Category: S2]]

Latest revision as of 20:26, 12 August 2015

This is an extension of Hierarchy, where you are introduced into the wild and baffling world of layouts and view functions. If you haven't been there yet, start there or this might not make much sense.

Purpose

Each of these pages is specifically designed to follow a function from how it appears in a view page down to its root functions, variables, and properties. Basically, by the end, you should understand in theory why a function exists and how its put together. Eventually, you will also be able to understand how to alter, change, and even override the functions and both where their variables are stored and why they're there.


In the Beginning

Add text.


Function: print_time

Add text.


class Entrylite

Functions

function print_time () [fixed];
Print the time of this post, with most useful information for user, and with tooltip for more.
function print_time (string datefmt, string timefmt) [fixed];

Print the time of the post, with customized date/time formats.

Stucture

function EntryLite::print_time() 
{
    print $this->time_display();
}


function EntryLite::time_display() : string 
{
    return $this->time_display("", "");
}
Let the real function decide on some nice defaults


function EntryLite::time_display(string datefmt, string timefmt) : string 
{
    if ($datefmt == "") {$datefmt = "med";}
    if ($timefmt == "") {$timefmt = "short";}
 
    var string ret;
    if ($datefmt != "none") { $ret = $ret + $this.time->date_format($datefmt); }
    if ($datefmt != "none" and $timefmt != "none") { $ret = $ret + " "; }
    if ($timefmt != "none") { $ret = $ret + $this.time->time_format($timefmt); }
    return $ret;
}
function builtin date_format () : string;
Returns date formatted as normal. /// SeeAlso: siteapi.core1.dateformats"
function builtin date_format (string fmt) : string;
Returns date formatted as indicated by \$fmt. One of: short, med, long, med_day, long_day. Or a custom format. Default is 'short'. /// SeeAlso: siteapi.core1.dateformats
function builtin date_format (string fmt, bool linkify) : string;
Returns date formatted in the same way as calling date_format(string fmt), but with day, month, and year as links to the corresponding archive pages.
function builtin time_format () : string;
Returns time formatted as normal. /// SeeAlso: siteapi.core1.dateformats
function builtin time_format (string fmt) : string;
Returns time formatted as indicated by \$fmt, or normal if blank. /// SeeAlso: siteapi.core1.dateformats

class Comment

Function

function Comment::print_time (string datefmt, string timefmt, bool edittime);
Same as EntryLite::print_time, except can pass in if we want the edit time or not.

Stucture

function Comment::print_time (string datefmt, string timefmt) 
{
    $this->print_time($datefmt, $timefmt, false);
}

class Page

Function

function Page::print_time();
Print the time when the page was created.

Structure:

function Page::print_time() 
{
    $this->print_time("","");
}
function Page::print_time(string datefmt, string timefmt) 
{
    if ($datefmt == ""){$datefmt = "med";}
    if ($timefmt == ""){$timefmt = "short";}
    var string ret;
    if ($datefmt != "none") { $ret = $ret + $this.local_time->date_format($datefmt); }
    if ($datefmt != "none" and $timefmt != "none") { $ret = $ret + " "; }
    if ($timefmt != "none") { $ret = $ret + $this.local_time->time_format($timefmt); }
    print safe """<span id="load-time">$*text_generated_on $ret</span>""";
}

Associated Properties

Associated Properties

property string[] entry_datetime_format_group 
{
   des = "Entry date/time format";
grouptype = "datetime";
}
property string entry_date_format 
{ 
    des = "Entry date format";
    values = "short|2/5/80|med|Feb. 5th, 1980|med_day|Tue, Feb. 5th, 1980|long|February 5th, 1980|long_day|Tuesday, February 5th, 1980";
    grouped = 1;
}
property string entry_time_format 
{
    des = "Entry time format.";
    values = "short|12:34am";
    grouped = 1;
}
property string[] comment_datetime_format_group 
{
    des = "Comment date/time format";
    grouptype = "datetime";
}
property string comment_date_format 
{ 
    des = "Comment date format";
    values = "short|2/5/80|med|Feb. 5th, 1980|med_day|Tue, Feb. 5th, 1980|long|February 5th, 1980|long_day|Tuesday, February 5th, 1980";
    grouped = 1;
}
property string comment_time_format 
{
    des = "Comment time format.";
    values = "short|12:34am";
    grouped = 1;
}
set entry_datetime_format_group = ["entry_date_format", "entry_time_format"];
set entry_date_format = "short";
set entry_time_format = "short";
set comment_datetime_format_group = ["comment_date_format", "comment_time_format"];
set comment_date_format = "short";
set comment_time_format = "short";

Conclusion

Add text.