node.\+js formatting of Date objects as strings. Probably exactly the same as some other library out there.


\begin{DoxyCode}{0}
\DoxyCodeLine{npm install date-\/format }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_streamroller_node_modules_date_format_README_autotoc_md28946}{}\doxysection{usage}\label{md_sfcode_node_modules_streamroller_node_modules_date_format_README_autotoc_md28946}
\hypertarget{md_sfcode_node_modules_streamroller_node_modules_date_format_README_autotoc_md28947}{}\doxysubsection{Formatting dates as strings}\label{md_sfcode_node_modules_streamroller_node_modules_date_format_README_autotoc_md28947}

\begin{DoxyCode}{0}
\DoxyCodeLine{var format = require('date-\/format');}
\DoxyCodeLine{format.asString(); //defaults to ISO8601 format and current date.}
\DoxyCodeLine{format.asString(new Date()); //defaults to ISO8601 format}
\DoxyCodeLine{format.asString('hh:mm:ss.SSS', new Date()); //just the time }

\end{DoxyCode}


or


\begin{DoxyCode}{0}
\DoxyCodeLine{var format = require('date-\/format');}
\DoxyCodeLine{format(); //defaults to ISO8601 format and current date.}
\DoxyCodeLine{format(new Date());}
\DoxyCodeLine{format('hh:mm:ss.SSS', new Date()); }

\end{DoxyCode}


Format string can be anything, but the following letters will be replaced (and leading zeroes added if necessary)\+:
\begin{DoxyItemize}
\item dd -\/ {\ttfamily date.\+get\+Date()}
\item MM -\/ {\ttfamily date.\+get\+Month() + 1}
\item yy -\/ {\ttfamily date.\+get\+Full\+Year().to\+String().substring(2, 4)}
\item yyyy -\/ {\ttfamily date.\+get\+Full\+Year()}
\item hh -\/ {\ttfamily date.\+get\+Hours()}
\item mm -\/ {\ttfamily date.\+get\+Minutes()}
\item ss -\/ {\ttfamily date.\+get\+Seconds()}
\item SSS -\/ {\ttfamily date.\+get\+Milliseconds()}
\item O -\/ timezone offset in +hm format (note that time will be in UTC if displaying offset)
\end{DoxyItemize}

Built-\/in formats\+:
\begin{DoxyItemize}
\item {\ttfamily format.\+ISO8601\+\_\+\+FORMAT} -\/ {\ttfamily 2017-\/03-\/14T14\+:10\+:20.\+391} (local time used)
\item {\ttfamily format.\+ISO8601\+\_\+\+WITH\+\_\+\+TZ\+\_\+\+OFFSET\+\_\+\+FORMAT} -\/ {\ttfamily 2017-\/03-\/14T03\+:10\+:20.\+391+1100} (UTC + TZ used)
\item {\ttfamily format.\+DATETIME\+\_\+\+FORMAT} -\/ {\ttfamily 14 03 2017 14\+:10\+:20.\+391} (local time used)
\item {\ttfamily format.\+ABSOLUTETIME\+\_\+\+FORMAT} -\/ {\ttfamily 14\+:10\+:20.\+391} (local time used)
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_streamroller_node_modules_date_format_README_autotoc_md28948}{}\doxysubsection{Parsing strings as dates}\label{md_sfcode_node_modules_streamroller_node_modules_date_format_README_autotoc_md28948}
The date format library has limited ability to parse strings into dates. It can convert strings created using date format patterns (as above), but if you\textquotesingle{}re looking for anything more sophisticated than that you should probably look for a better library (\href{https://momentjs.com}{\texttt{ momentjs}} does pretty much everything).


\begin{DoxyCode}{0}
\DoxyCodeLine{var format = require('date-\/format');}
\DoxyCodeLine{// pass in the format of the string as first argument}
\DoxyCodeLine{format.parse(format.ISO8601\_FORMAT, '2017-\/03-\/14T14:10:20.391');}
\DoxyCodeLine{// returns Date }

\end{DoxyCode}
 