Plugin Directory

Changeset 1174699


Ignore:
Timestamp:
06/04/2015 07:34:43 PM (11 years ago)
Author:
doddo
Message:

added SOL stardate fmt.

Location:
wp-stardate/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • wp-stardate/trunk/src/options.php

    r1159122 r1174699  
    6161     * @var string $input the input to validate
    6262     */
    63     return ( in_array($input, array('XI', 'XI_wikipedia')) ? $input : 'Classic');
     63    return ( in_array($input, array('XI', 'XI_wikipedia', 'SOL')) ? $input : 'Classic');
    6464}
    6565
     
    105105            <input name="stardate_style" type="radio" value="XI" <?php checked( 'XI', get_option( 'stardate_style' ) ); ?> /> XI (trekguide) <code><?php echo stardate_now('XI')?></code>
    106106            <input name="stardate_style" type="radio" value="XI_wikipedia" <?php checked( 'XI_wikipedia', get_option( 'stardate_style' ) ); ?> /> XI (wikipedia) <code><?php echo stardate_now('XI_wikipedia')?></code>
     107            <input name="stardate_style" type="radio" value="SOL" <?php checked( 'SOL', get_option( 'stardate_style' ) ); ?> /> StarTrek Online (SOL) <code><?php echo stardate_now('SOL')?></code>
    107108          </td>
    108109        </tr>
  • wp-stardate/trunk/stardate.php

    r1160392 r1174699  
    8585            'rewrite' => TRUE
    8686            )
     87        );
     88        register_taxonomy(
     89                'stardate-parent',
     90                'post',
     91                array(
     92          'hirarchical' => TRUE
     93                       
     94                  )
    8795        );
    8896    }
     
    219227         */
    220228        $stardate = mysql2date("Y.z", $date);
     229    } elseif ($style == 'SOL') {
     230        /* Represent the current date in YYMM.DD format, where "YY" is the current year minus 1900,
     231         * MM is the current month (01-12), and DD is the current day of the month (01-31).
     232        */
     233        $yy = mysql2date("Y", $date);
     234        $day_of_year = mysql2date("z", $date);
     235       
     236        if ($day_of_year > 143.9)
     237        {
     238            $day_of_year -= 143.9;
     239            $yy -= 1922;
     240        } else {
     241            $day_of_year +=  221.3422;
     242            $yy -= 1923;
     243        }
     244
     245        $dd =   $day_of_year / 365.2422 * 1000;
     246        $ff = ($dd - (int)$dd) * 100;
     247        $stardate = sprintf("%s%03s.%01s", $yy, (int)$dd, (int)$ff);
    221248    } else {
    222249        /* Represent the current date in YYMM.DD format, where "YY" is the current year minus 1900,
Note: See TracChangeset for help on using the changeset viewer.