Composr: Tempcode Symbol SEASON of the year

Let us talk about scripts, HTML, Perl, PHP, apache, etc.
Post Reply
User avatar
Stevyn
SysOp
Posts:1786
Joined:Mon Nov 09, 2009 10:03 am
Location:Japan
Contact:
Composr: Tempcode Symbol SEASON of the year

Post by Stevyn » Fri Jul 26, 2019 1:50 pm

Tempcode symbol SEASON to show the season of the year.

sources/hooks/systems/symbols/SEASON.php

Code: Select all

<?php

class Hook_symbol_SEASON
{

    public function run($param)
    {
    //start
 // get today's date
$today = new DateTime();

// get the season dates
$spring = new DateTime('March 20');
$summer = new DateTime('June 20');
$fall = new DateTime('September 22');
$winter = new DateTime('December 21');

switch(true) {
    case $today >= $spring && $today < $summer:
        $value= 'Spring';
        break;

    case $today >= $summer && $today < $fall:
       $value= 'Summer';
        break;

    case $today >= $fall && $today < $winter:
        $value= 'Fall';
        break;

    default:
        $value= 'Winter';
}
        return $value;
    }
}
code from: https://stackoverflow.com/questions/408 ... ccordingly

usage:

Code: Select all

{$SEASON}
Contact me directly: Ironfeatherbooks (@) gmail.com

Image

User avatar
Stevyn
SysOp
Posts:1786
Joined:Mon Nov 09, 2009 10:03 am
Location:Japan
Contact:

Re: Composr: Tempcode Symbol SEASON of the year

Post by Stevyn » Fri Jul 26, 2019 4:39 pm

example of code to make a sunrise tempcode symbol

Code: Select all

date_default_timezone_set("Asia/Tokyo");
 $value = date("g:i a",(date_sunrise(time(),SUNFUNCS_RET_TIMESTAMP,43.4,141.21,90,9)));
Contact me directly: Ironfeatherbooks (@) gmail.com

Image

User avatar
Stevyn
SysOp
Posts:1786
Joined:Mon Nov 09, 2009 10:03 am
Location:Japan
Contact:

Re: Composr: Tempcode Symbol SEASON of the year

Post by Stevyn » Fri Jul 26, 2019 6:36 pm

Composr: Tempcode Symbol greeting of the day:

Code: Select all

<?php

class Hook_symbol_GREETING
{

    public function run($param)
    {
    //start
    /* This sets the $time variable to the current hour in the 24 hour clock format */
   date_default_timezone_set("Asia/Tokyo");
    $time = date("H");  
    /* Set the $timezone variable to become the current timezone */
   //  $timezone = date("e");
    /* If the time is less than 1200 hours, show good morning */
    if ($time < "12") {
return "morning";
    } else
    /* If the time is grater than or equal to 1200 hours, but less than 1700 hours, so good afternoon */
    if ($time >= "12" && $time < "17") {
        return "afternoon";
    } else
    /* Should the time be between or equal to 1700 and 1900 hours, show good evening */
    if ($time >= "17" && $time < "19") {
        return "evening";
    } else
    /* Finally, show good night if the time is greater than or equal to 1900 hours */
    if ($time >= "19") {
        return "night";
    }

 
       
    }
}

Contact me directly: Ironfeatherbooks (@) gmail.com

Image

Post Reply