Skip to content

Instantly share code, notes, and snippets.

@ebraminio
Created January 8, 2015 21:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ebraminio/546e1f896b751add8789 to your computer and use it in GitHub Desktop.
Save ebraminio/546e1f896b751add8789 to your computer and use it in GitHub Desktop.
var months = 'فروردین اردیبهشت خرداد تیر مرداد شهریور مهر آبان آذر دی بهمن اسفند'.split(' ');
var result = [];
$("#wpTextbox1").val().replace(/علیهالسلام/g, 'علیه‌السلام').split('\n').forEach(function (x) {
var p = x.split(' ');
result.push('<holiday day="' + p.splice(-1)[0].replace(/[۰-۹]/g, function (x) { return String.fromCharCode(x.charCodeAt(0) - '۰'.charCodeAt(0) + '0'.charCodeAt(0)); }) + '" month="' + (months.indexOf(p.splice(-1)[0]) + 1) + '" year="1394">' + p.join(' ') + '</holiday>');
});
result.join('\n');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment