This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
React.useEffect(()=>{ | |
let openRequest = indexedDB.open("testingIndexedDB", 1); | |
openRequest.onupgradeneeded = function() { | |
// triggers if the client had no database or the client has a higher version | |
// ...perform initialization... | |
console.log("onupgradeneeded"); | |
let db = openRequest.result; | |
console.log(db) | |
}; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const regex = /\d+-\d+-d+/; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//testing if exampleString includes the regex pattern. | |
const regexPattern=/\s+[0-9]+-[0-9]+-[0-9]+\s+/; | |
const exampleString = | |
"Hi~ call me this number 093-5353-6234 after" + | |
" 4:30 pm or email me at tofusoup429@gmail.com anytime."; | |
const result1 = regexPattern.test(exampleString); | |
console.log("output: ",result1); | |
//output: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//extract more information for substring that matches exampleString. | |
const regexPattern=/\s+[0-9]+-[0-9]+-[0-9]+\s+/; | |
const exampleString = | |
"Hi~ call me this number 093-5353-6234 after" + | |
" 4:30 pm or email me at tofusoup429@gmail.com anytime."; | |
const result2 = regexPattern.exec(exampleString); | |
console.log("output: ",result2); | |
/*output: [ | |
' 093-5353-6234 ', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//ver 1.0.7 | |
export const excelDateToJSDate = (date:number):Date => { | |
//takes a number and return javascript Date object | |
return new Date(Math.round((date - 25569)*86400*1000)); | |
} | |
export const jsDateToExcelDate = (date:Date):number => { | |
//takes javascript a Date object to an excel number | |
let returnDateTime = 25569.0 + ((date.getTime()-(date.getTimezoneOffset() * 60 * 1000)) / (1000 * 60 * 60 * 24)); | |
return Math.floor(returnDateTime) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {jsDateToExcelDate} from '@tofusoup429/excel-date-handlers' | |
let jsdate = new Date(2015,2,25) | |
let jsdatetoexceldate = jsDateToExcelDate(jsdate); | |
console.log(jsdatetoexceldate); | |
//42088 | |
//note that the month of date instance starts from 0. In order to pass march, you should pass 2 instead of 3. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {addDates} from '@tofusoup429/excel-date-handlers' | |
let addDate = addDates('20200131', 2, 'yyyy-mm-dd'); | |
console.log(addDate) | |
//prints "2020-02-02", not "2020-01-33" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const {excelDateToStringDateFormat} = require('@tofusoup429/excel-date-handlers'); | |
let stringdate= excelDateToStringDateFormat(42088,'yyyy-mm-dd'); | |
console.log(stringdate); | |
//2015-03-25 | |
let stringdate= excelDateToStringDateFormat(42088,'yyyy/mm/dd'); | |
console.log(stringdate); | |
//2015/03/25 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const {excelDateToJSDate} = require('@tofusoup429/excel-date-handlers'); | |
let excelDateToJsDate = excelDateToJSDate(42088); | |
console.log(excelDateToJsDate); | |
//2015-03-25T00:00:00.000Z |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Item, Pro, Con | |
webStorage, aaa, bbb | |
IndexedDB, aaa, bbb |
OlderNewer