What is gloomyDate.js?

intro

you guys should faced problem with calculating Date. But now on, you can convert the date with gloomyDate.js!
you've ever felt difficulty in converting Date in board, comment, and so on... you can put the string in gloomyDate.date(str), and convert the date with using gloomyDate.

developers may love it.


function App() {
  const [data,setData] = useState([{ title: 'title1', date: '2022-05-10 10:55:40'}, { title: 'title2', date: '2023-02-11 15:50:30'}])
  useEffect(()=>{
    const newData = [...data]
    newData.forEach(e=> e.date = gloomyDate.date(e.date,'en'))
    setData(newData)
  },[])
  return (
    
{ data.map((elm,idx)=>

{e.title}

{e.date}

{/* expected: 1 years ago */}
) }
); }


Expected


title1
1 years ago

title2
2 months ago



deployment

being deplyed by npm publish.


npm i gloomydate

makes your package has gloomyDate

i made this ES Module because of regarding tree shaking, and will make this with named export.

you can use gloomyDate in common html project


<script src="https://cdn.gloomy-store.com/gloomyDate/gloomyDate.js"></script>


(not the module system)

and manual is same with React's



this support with 3 global language, and input will be 3 types.


gloomyDate.date('2023-04-26 08:10:22','en') // formatted string
gloomyDate.date('20230426081022','jp') // string
gloomyDate.date(20230426081022,'ko') // number


'ko', 'jp', 'en'
3 language supported

Expected:


2days ago
2日前
2일 전

default value is korean. ('ko')

input should be 14 length of string, number,
and it can support format of 'YY-mm-dd H:i:s'

Demo