Skip to main content

Backup malarky and prelimary theAbysmal scripts

Posted on: Sunday, 18 December 2011 @ 3:17pm
Blatting about

If this post disappears, it's entirely my fault as I told the provider that this site could just be rolled back to the last backup (assuming the last backup he had was more recent than the one I had).

What happened with the backups? It's a long and sordid story.

Actually it's not that long, just slightly confusing.  See the provider does scheduled backups as all decent providers should.  But last month and earlier this month something very strange happened.  Three of my sites (this one, Red Planet and WANLN) lost a month's worth of posts.   It's entirely possible the other ones rolled back as well but these ones were the most noticable as they get updated constantly.

The backups were supposed to have been done about the time the rollbacks happened so my current hypothesis is that either the backup is happening and then it's restoring from a backup for some bizarre reason, or it's restoring from backup instead of backing up, or restoring from backup and then backing up.  Hopefully not either of the last two as if that's the case the stuff is gone for good and I'm hoping the lost posts can be merged back in from the backups into the current.  Will see how we go.  I'm really hoping it gets resolved sooner rather than later as my internet access is going to be sloooowwwwww from Christmas Island.

I recently hacked together a script to convert Gregorian dates to theAbysmal dates for use in AEfter Ragnarok.  A couple of people on Diaspora* were interested in it, so I said I'd put it up here when I sorted the problems out.  The problems aren't sorted but it's here anyway :)

20) { $year = date('Y', $ce_raw) - date('Y', $zero_date); } else { $year = (date('Y', $ce_raw) - date('Y', $zero_date)) - 1; } // adjusting leap years if ($year % 4 == 0) { $ly = 1; if ($year % 128 == 0) { $ly = 0; } } else { $ly = 0; } if (date('L', $ce_raw)) { $gly = 1; } else { $gly = 0; } $length_modifier = $gly + $ly; // how many days in the year? +1 to make it an absolute value $year_length = date('z', mktime(0, 0, 0, 12, 31, $year_ce)) + 1 + $ly - $gly; // first work out what the year day number the supplied date is, add a day if it's a leap year $gregorian_day_of_year = date('z', $ce_raw); // how many days have passed since theAbysmal started, take off the extra days the leap year adds $days_from_start = ($gregorian_day_of_year - $zero_day + $year_length - $gly) % $year_length; // theAbysmal month converted to an integer $month_number = intval($days_from_start / 28); // what day in the month it is $mday = $days_from_start % 28; // lojban day names and assigning to month days $days = array( 'xundei' => array('0', '7', '14', '21'), 'najdei' => array('1', '8', '15', '22'), 'peldei' => array('2', '9', '16', '23'), 'ri\'ordei' => array('3', '10', '17', '24'), 'cicnydei' => array('4', '11', '18', '25'), 'bladei' => array('5', '12', '19', '26'), 'zirdei' => array('6', '13', '20', '27'), ); foreach($days as $key => $value) { if (in_array($mday, $value)) { $weekday = $key; } } // Tranquility calendar month names // the 14th "month" is a 2 day intercalary period for New Year Day and Leap Year Day $months = array( '0' => 'Archimedes', '1' => 'Brahe', '2' => 'Copernicus', '3' => 'Darwin', '4' => 'Einstein', '5' => 'Faraday', '6' => 'Galileo', '7' => 'Hippocrates', '8' => 'Imhotep', '9' => 'Jung', '10' => 'Kepler', '11' => 'Lavoisier', '12' => 'Mendel', '13' => '', ); foreach($months as $key => $value) { if ($key == $month_number) { $month = $value; } } /* * intercalary days * * check to see if it's December Solstice * if it is, it's New Year Day * if not, it's a weekday * * if it's a leap year and it's December Solstice * it's Leap Year Day and everything is offset by 1 */ $nyd = mktime(0, 0, 0, 12, 21, $year_ce); $lyd = mktime(0, 0, 0, 12, 20, $year_ce); if ($month == '') { $weekday = ''; if ($ce_raw == $nyd) { $mday = "New Year Day"; } if ($ly == 1 && $ce_raw == $lyd) { $mday = "Leap Year Day"; } } $yrabs = abs($year); $yrlen = strlen($yrabs); if ($ce_raw < $zero_date) { $sign = '-'; } elseif ($year == '0000') { $sign = ''; } else { $sign = ''; } if ($yrlen == 1) { $year = '000' . $yrabs; } elseif ($yrlen == 2) { $year = '00' . $yrabs; } elseif ($yrlen == 3) { $year = '0' . $yrabs; } ?>

And a form to convert any date (defaults to today):

Gregorian:
theAbysmal:

It's a bit quick and dirty and probably hacky and could use improvements, so suggestions and improvements welcome. I'm a cheap module hack, still learning :) To use it whack it in a php file. If you don't like the names of the months and days, change 'em in the arrays. Officially theAbysmal weeks start on Saturday.

I also converted it into a Drupal module.  Today's converted date can be seen at the top of the sidebar, the post converted date is embedded under the title.  The tags have been moved to the bottom of the post.  The shortened date notation is my invention, as is the usage of lojban words for the week day names and Tranquility months for the month names.  The actual theAbysmal Calendar uses the current weekday names and I think just numbers (Month 0, Month 1 etc) for month names.

No comments yet

Not Jack Friday, 17 February 2012 @ 5:06am [Permalink]
awesome work - not that I can read code any better than ancient Chinese - but cool.
bek Friday, 17 February 2012 @ 5:47pm [Permalink]

Add new comment

The content of this field is kept private and will not be shown publicly.