Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

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 shirshak55/27f1173d33287565057d5e97310ea337 to your computer and use it in GitHub Desktop.
Save shirshak55/27f1173d33287565057d5e97310ea337 to your computer and use it in GitHub Desktop.
I needed to conver massive date from AD (English Date) to Nepali Date (Bikram Sambat) for wikipedia. So I wrote the following script. I did it so i can change https://en.wikipedia.org/wiki/Nepalese_Civil_War
let unformatted_dates = [
"13 February 1996",
"January 2001",
"28 May 2001",
"1 June 2001",
"3 August 2001",
"23 November 2001",
"26 November 2001",
"May 2002",
"May 2002",
"22 May 2002",
"11 July 2002",
"4 October 2002",
"11 October 2002",
"January 2003",
"29 January 2003",
"13 May 2003",
"17 August 2003",
"24 August 2003",
"26 August 2003",
"27 August 2003",
"28 August 2003",
"29 August 2003",
"31 August 2003",
"2 September 2003",
"27 September 2003",
"13 October 2003",
"27 October 2003",
"11 November 2003",
"15 November 2003",
"19 November 2003",
"5 February 2004",
"10 February 2004",
"13 February 2004",
"15 February 2004",
"15 February 2004",
"15 February and 16 2004",
"18 February 2004",
"2 April 2004",
"3 April 2004",
"4 April 2004",
"4 April 2004",
"4 April 2004",
"5 April 2004",
"5 April 2004",
"5 April 2004",
"5 April 2004",
"24 June 2004",
"16 August 2004",
"18 August 2004",
"10 September 2004",
"13 September 2004",
"9 November 2004",
"11 November 2004",
"15 December 2004",
"16 December 2004",
"23 December 2004",
"26 December 2004",
"2 January 2005",
"4 January 2005",
"8 January 2005",
"10 January 2005",
"11 January 2005",
"15 January 2005",
"29 January 2005",
"1 February 2005",
"6 June 2005",
"9 August 2005",
"3 September 2005",
"19 November 2005",
"2 January 2006",
"14 January 2006",
"14 March 2006",
"5 April 2006",
"6 April 7, 2006",
"8 April 2006",
"9 April 2006",
"26 April 2006",
"27 April 2006",
"3 May 2006",
"21 November 2006",
]
let eng_date = [];
async function main(){
for(let unformatted_date of unformatted_dates){
let date = new Date(unformatted_date)
if(date instanceof Date && !isNaN(date)){
let yy = date.getFullYear()
let mm= date.getMonth()+1
let dd = date.getDate()
let resp = await fetch("https://rejeena.com.np/date-converter/", {
"credentials": "include",
"headers": {
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:77.0) Gecko/20100101 Firefox/77.0",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
"Accept-Language": "en-US,en;q=0.5",
"Content-Type": "application/x-www-form-urlencoded",
"Upgrade-Insecure-Requests": "1"
},
"referrer": "https://rejeena.com.np/date-converter/",
"body": `engyear=${yy}&engmon=${mm}&engday=${dd}&eng_submit=Convert+to+Nepali`,
"method": "POST",
"mode": "cors"
});
let text = await resp.text();
let to_push = text.match(/Nepali \(BS\) \: \<br\ \/\>\n([^<]*)/)[1]
eng_date.push({o:unformatted_date,n: to_push})
console.log(yy,mm,dd,unformatted_date,to_push)
}else{
eng_date.push({o:unformatted_date,n: null})
}
}
}
main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment