Skip to content

Instantly share code, notes, and snippets.

@kazua
kazua / convDate2.php
Created December 26, 2013 15:54
PHPで西暦⇔和暦変換
<?php
//write kazua
function convGtJDate($src) {
list($year, $month, $day) = explode('/', $src);
if (!@checkdate($month, $day, $year) || $year < 1869 || strlen($year) !== 4
|| strlen($month) !== 2 || strlen($day) !== 2) return false;
$date = str_replace('/', '', $src);
if ($date >= 19890108) {
$gengo = '平成';
@DQNEO
DQNEO / isbn13to10.js
Last active November 6, 2020 23:22
JavaScriptでISBN13をISBN10に変換する関数。
/**
* ISBN13をISBN10に変換する関数。
*
* Usage
* console.log(isbn13to10("9784063842760"));
* > "4063842762"
*
* # 変換ロジックの解説(例:"9784063842760")
* 1. ISBN13の先頭3文字と末尾1文字を捨てる => "4063842760"
* 2. 4*10 + 0*9 + 6*8 + 3*7 + 8*6 + 4*5 + 2*4 +7*3 + 6*2 = 218