All times are UTC [ DST ]




Post new topic Reply to topic  [ 32 posts ]  Go to page Previous  1, 2, 3, 4  Next
Author Message
  Offline
PostPosted: September 10th, 2016, 6:35 pm 
User avatar
King

Joined: May 30th, 2015, 7:09 pm
Posts: 1086
Okies

_________________
By the will of Azarn
-Erastil
-King of Pyrencia
-The Hydra
For a full list of titles, please see enclosed document.
viewtopic.php?f=4&t=741


Top
 Profile  
Reply with quote  
  Offline
PostPosted: September 10th, 2016, 9:32 pm 
User avatar
King

Joined: May 30th, 2015, 10:17 am
Posts: 3862
Location: Stirling - Scotland
yeah. I was confused also Myron for a second but it makes sense. I'm happy for that to be the case for dates

_________________
Petra Ravnikaar of The Veil


Top
 Profile  
Reply with quote  
  Offline
PostPosted: September 16th, 2016, 8:42 pm 
King

Joined: February 24th, 2016, 8:29 pm
Posts: 563
It might be a false fix, as I have not tested it (and am a bit to tipsy to fully think through the algorithmic logic), but I think we can fix the cycle dating with the following edit.

Change:
Code:
$cycle_merc_padded = sprintf("%02d", $cycle_merc);


To:

Code:
$cycle_merc_padded = sprintf("%02d", $cycle_merc) - 1;


Seems too good to be true, but all i did was minus a '1' from the current counter, which appears to be correct on the mercannum part (3) but incorrect on the first part (says 1, when it should say 0?)

Will happily test this edit out with Siden once he gets a chance to add it. Also, has the other edit (fix) been added already? I highly recommend it if it hasn't. I haven't been paying attention, is the date accurate? As for the calendar converter, we can worry about that part later with a collaborative hang out.


Top
 Profile  
Reply with quote  
  Offline
PostPosted: October 1st, 2016, 9:53 am 
King

Joined: February 24th, 2016, 8:29 pm
Posts: 563
Siden is our great and noble manager of oh so many things. But out of curiousity, does anyone else have access to the website server files? I'd hate to keep bothering Siden, and I notice our date formula has not been updated in quite a while (it's a copy paste job). If no one else has access, should we elect a new minister perhaps? To take the burden off of our good sir?


Top
 Profile  
Reply with quote  
  Offline
PostPosted: October 1st, 2016, 9:54 am 
King

Joined: February 24th, 2016, 8:29 pm
Posts: 563
Such a minister might be helpful for the library work too.


Top
 Profile  
Reply with quote  
  Offline
PostPosted: October 2nd, 2016, 5:22 pm 
King

Joined: February 24th, 2016, 8:29 pm
Posts: 563
Corrected code below:
Quote:
<?php
$day = date('d'); //today
$mercannum = $day / 6;
$base_year = -2; //for tweaking
if ($day >= 0 && $day < 1) { //saves extra years to be added into months below.
$extra_year = $base_year;
} else if ($day >= 6 && $day < 11) {
$extra_year = $base_year +1;
} else if ($day >= 11 && $day < 16) {
$extra_year = $base_year +2;
} else if ($day >= 16 && $day < 21) {
$extra_year = $base_year +3;
} else if ($day >= 21 && $day < 26) {
$extra_year = $base_year +4;
} else if ($day >= 26) {
$extra_year = $base_year +5; }

?><BR><?php
$date1 = '2009-01-01'; // 000 AI, although off by 37 on purpose (a needed fix, as starting at the beginning of the year makes all later calculations easier)
//$date2 = '2016-08-03'; Blank, used for testing
$date2 = date('Y-m-d'); //current date (full)
$ts1 = strtotime($date1); //convert string
$ts2 = strtotime($date2);
$year1 = date('Y', $ts1); //convert string year only
$year2 = date('Y', $ts2);
$month1 = date('m', $ts1); //convert string month only
$month2 = date('m', $ts2);
$month_diff = (($year2 - $year1) * 12) + ($month2 - $month1); //months between base and today
$canonyears_diff = $month_diff * 6;
$current_year = $canonyears_diff + $extra_year - 38;
?><strong><?php echo "Years of the Emperor: "; ?></strong><?php echo $current_year . " AI ";

$date3 = '2016-08-31'; // All of the below behaves like the above, but calculates cycles instead
$ts1 = strtotime($date3);
$ts2 = strtotime($date2);
$year1 = date('Y', $ts1);
$year2 = date('Y', $ts2);
$month1 = date('m', $ts1);
$month2 = date('m', $ts2);
$cycle_check_month_diff = (($year2 - $year1) * 12) + ($month2 - $month1);
//echo $month_diff;
$cycle_base = '2015-06-01';
$ts1 = strtotime($cycle_base);
$ts2 = strtotime($date2);
$year1 = date('Y', $ts1);
$year2 = date('Y', $ts2);
$month1 = date('m', $ts1);
$month2 = date('m', $ts2);
$cycle_month_diff = (($year2 - $year1) * 12) + ($month2 - $month1);
$cycle_merc = round($cycle_month_diff / 12);
$cycle_merc2 = $cycle_merc -1;
$cycle_year = $cycle_month_diff % 12;

$cycle_merc_padded = sprintf("%02d", $cycle_merc2);
$cycle_year_padded = sprintf("%02d", $cycle_year);

if ($cycle_check_month_diff > 1) {
?><strong><?php echo "| Cycle of the Tide: "; ?></strong><?php echo $cycle_merc_padded; ?><strong><?php echo "-"; ?></strong><?php echo $cycle_year_padded;
} else {
?><strong><?php echo "| Cycle of the Phoenix: "; ?></strong><?php echo $cycle_merc_padded; ?><strong><?php echo "-"; ?></strong><?php echo $cycle_year_padded;
}
?>



And the code for the calendar converter:

The below part loads external plugins and loads the calendar function. Place at the top of the page, such as above the <body>
Quote:
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.0/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.0/jquery-ui.js"></script>
<script>
$( function() {
$( "#datepicker" ).datepicker();
} );
</script>


This below part creates the clickable button (the text that needs to be clicked to expose the calendar). Easily modifiable. Just don't change the div name, id, or class names. Place whereever you want the calendar convert to sit.
Quote:
<div style="font-style: italic;" id="hide_calendar">Click to toggle calendar converter</div>
<div id="hidden_calendar">
<div id="calendar"></div>
<p>Converted Date: <input class="target" type="text" id="datepicker2" readonly></p>
</div>



And finally:
This is the code to make the calendar converter itself. It's usually easiest to put this at the very bottom of the page (but still inside the <body>).
Quote:
<script>

$( document ).ready(function() {
$("#hidden_calendar").hide();
});

$( ".target" ).change(function() {
//var value = this.value; // omit "var" to make it global
//var date1 = '07/31/2009';
//$(".target").text(value);
//alert( value );
});

$('#calendar').datepicker({
dateFormat: 'yy-m-d',
inline: true,
onSelect: function(dateText, inst) {
var date = $(this).datepicker('getDate'),
day = date.getDate(),
month2 = date.getMonth() + 1,
year2 = date.getFullYear();

var date1 = '7-31-2009';
var month1 = '7';
var year1 = '2009';
month_diff = ((year2 - year1) * 12) + (month2 - month1);
canonyears_diff = month_diff * 6;

base_year = -2;
if (day >= 0 && day < 6) {
extra_year = base_year;
} else if (day >= 6 && day < 11) {
extra_year = base_year +1;
} else if (day >= 11 && day < 16) {
extra_year = base_year +2;
} else if (day >= 16 && day < 21) {
extra_year = base_year +3;
} else if (day >= 21 && day < 26) {
extra_year = base_year +4;
} else if (day >=26) {
extra_year = base_year +5;
}

current_year = canonyears_diff + extra_year;

$('#datepicker2').val(current_year + ' AI');

}
});

$("#hide_calendar").click(function(){
$("#hidden_calendar").toggle();
});

</script>


Top
 Profile  
Reply with quote  
  Offline
PostPosted: October 2nd, 2016, 5:23 pm 
King

Joined: February 24th, 2016, 8:29 pm
Posts: 563
A working example of both can be found here:

http://codydodd.ca/hermertia/cal.php


Top
 Profile  
Reply with quote  
  Offline
PostPosted: October 6th, 2016, 2:29 pm 
King

Joined: February 24th, 2016, 8:29 pm
Posts: 563
So the Regent is a boob. The long and giant code was causing me such grief, and was wrong AGAIN. so I decided to employ occam's razor. I decided to rewrite the whole thing based on a simpler (and now much more functional) code. Siden, all you need to do is replace the entire long calendar code with the following:

Quote:
$day = date('d'); //today
$month2 = date('m'); //today's month
$year2 = date('Y'); //today's year
$month1 = 7;
$year1 = 2009;
$month_diff = (($year2 - $year1) * 12) + ($month2 - $month1);
$canonyears_diff = $month_diff * 6;
$base_year = -2;
if ($day >= 0 && $day < 6) {
$extra_year = $base_year;
} else if ($day >= 6 && $day < 11) {
$extra_year = $base_year +1;
} else if ($day >= 11 && $day < 16) {
$extra_year = $base_year +2;
} else if ($day >= 16 && $day < 21) {
$extra_year = $base_year +3;
} else if ($day >= 21 && $day < 26) {
$extra_year = $base_year +4;
} else if ($day >=26) {
$extra_year = $base_year +5;
}
$current_year = $canonyears_diff + $extra_year;
?><BR><?php
?><strong><?php echo "Years of the Emperor: "; ?></strong><?php echo $current_year . " AI ";
$cycle_base_year = 2016; //CHANGE THIS IF ENTERING A NEW CYCLE
if ($month2 < 6) {
$month3 = $month2 + 6;
$cycle_base_year = $cycle_base_year - 1;
} else {
$month3 = $month2 - 6;
}
$month_padded = sprintf("%02d", $month3);
$mercannum = $cycle_base_year - $year2;
$mercannum_padded = sprintf("%02d", $mercannum);

?><strong><?php echo "| Cycle of the Tide: "; ?></strong><?php echo $mercannum_padded; ?><strong><?php echo "-"; ?></strong><?php echo $month_padded; ?>


So much simpler and cleaner, and now finally accurate! :X


Top
 Profile  
Reply with quote  
  Offline
PostPosted: October 6th, 2016, 5:02 pm 
User avatar
King

Joined: May 30th, 2015, 5:52 pm
Posts: 934
Thanks Regent! Your commitment to ensuring the success of this is much appreciated.

_________________
Wysterian Labourer's Council
Currently Holding Stewardship of Wysteria

Minister for Applications and Settlement
Forums Administrator


Top
 Profile  
Reply with quote  
  Offline
PostPosted: October 6th, 2016, 7:42 pm 
King

Joined: February 24th, 2016, 8:29 pm
Posts: 563
My pleasure! I cant wait to share the latest project I have been cooking up. Im almost done a beta version of a character integration system, which will be woven into the forum and library. Ill need support from a few people with access to the ftp files for the website though


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 32 posts ]  Go to page Previous  1, 2, 3, 4  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 12 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group
Imperium - Modified by Rey phpbbmodrey