mirror of
https://github.com/artegoser/AnoPaper.git
synced 2024-11-25 13:26:22 +03:00
refactor: change printDate to timestamp2text
This commit is contained in:
parent
80858f53d9
commit
3f705bf8c4
7 changed files with 15 additions and 15 deletions
|
@ -16,7 +16,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import RenderMarkdown from "../components/markdown";
|
import RenderMarkdown from "../components/markdown";
|
||||||
import { printDate } from "./utils";
|
import { timestamp2text } from "./utils";
|
||||||
|
|
||||||
function Note({ note }) {
|
function Note({ note }) {
|
||||||
return (
|
return (
|
||||||
|
@ -26,7 +26,7 @@ function Note({ note }) {
|
||||||
{note.name}
|
{note.name}
|
||||||
</h2>
|
</h2>
|
||||||
<div className="justify-self-center lg:justify-self-end">
|
<div className="justify-self-center lg:justify-self-end">
|
||||||
{`${printDate(note.time)} ${
|
{`${timestamp2text(note.time)} ${
|
||||||
note.pub ? `| ${locals.PublicNote}` : `| ${locals.LocalNote}`
|
note.pub ? `| ${locals.PublicNote}` : `| ${locals.LocalNote}`
|
||||||
}`}
|
}`}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
import { Locales } from "../localisation/main";
|
import { Locales } from "../localisation/main";
|
||||||
|
|
||||||
function printDate(time) {
|
function timestamp2text(time) {
|
||||||
time = new Date(time);
|
time = new Date(time);
|
||||||
return time.toLocaleString(settings.language);
|
return time.toLocaleString(settings.language);
|
||||||
}
|
}
|
||||||
|
@ -48,4 +48,4 @@ async function getNetLocale(lang, fileName) {
|
||||||
return (await (await fetch(`localisation/${lang}/${fileName}`)).text()) || "";
|
return (await (await fetch(`localisation/${lang}/${fileName}`)).text()) || "";
|
||||||
}
|
}
|
||||||
|
|
||||||
export { printDate, reRenderPage, localesProcess, getNetLocale };
|
export { timestamp2text, reRenderPage, localesProcess, getNetLocale };
|
||||||
|
|
|
@ -20,7 +20,7 @@ import { ChevronDoubleRightIcon } from "@heroicons/react/24/outline";
|
||||||
import { CheckBox } from "../components/checkbox";
|
import { CheckBox } from "../components/checkbox";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import RenderMarkdown from "../components/markdown";
|
import RenderMarkdown from "../components/markdown";
|
||||||
import { printDate } from "../components/utils";
|
import { timestamp2text } from "../components/utils";
|
||||||
import rehypeRemark from "rehype-remark/lib";
|
import rehypeRemark from "rehype-remark/lib";
|
||||||
import ContentEditable from "react-contenteditable";
|
import ContentEditable from "react-contenteditable";
|
||||||
import ReactDOMServer from "react-dom/server";
|
import ReactDOMServer from "react-dom/server";
|
||||||
|
@ -162,7 +162,7 @@ function CreateNote() {
|
||||||
{name}
|
{name}
|
||||||
</h2>
|
</h2>
|
||||||
<div className="justify-self-center lg:justify-self-end">
|
<div className="justify-self-center lg:justify-self-end">
|
||||||
{printDate(Date.now())}
|
{timestamp2text(Date.now())}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
import { ButtonWithIcon } from "../components/button";
|
import { ButtonWithIcon } from "../components/button";
|
||||||
import { ChevronDoubleRightIcon } from "@heroicons/react/24/outline";
|
import { ChevronDoubleRightIcon } from "@heroicons/react/24/outline";
|
||||||
import { printDate } from "../components/utils";
|
import { timestamp2text } from "../components/utils";
|
||||||
import Fuse from "fuse.js";
|
import Fuse from "fuse.js";
|
||||||
import { inputStyle } from "../components/styles";
|
import { inputStyle } from "../components/styles";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
@ -30,7 +30,7 @@ function Notes() {
|
||||||
let notes = Object.entries(notesObj);
|
let notes = Object.entries(notesObj);
|
||||||
for (let [id, note] of notes) {
|
for (let [id, note] of notes) {
|
||||||
note.id = id;
|
note.id = id;
|
||||||
note.textTime = printDate(note.time);
|
note.textTime = timestamp2text(note.time);
|
||||||
notesObj[id] = note;
|
notesObj[id] = note;
|
||||||
}
|
}
|
||||||
localStorage.setObj("Notes", notesObj);
|
localStorage.setObj("Notes", notesObj);
|
||||||
|
@ -82,7 +82,7 @@ function Notes() {
|
||||||
{item.name}
|
{item.name}
|
||||||
</div>
|
</div>
|
||||||
<div className="grid grid-cols-1 lg:grid-cols-2 justify-self-center lg:justify-self-end">
|
<div className="grid grid-cols-1 lg:grid-cols-2 justify-self-center lg:justify-self-end">
|
||||||
<div className="text-center">{printDate(item.time)}</div>
|
<div className="text-center">{timestamp2text(item.time)}</div>
|
||||||
<div className="">
|
<div className="">
|
||||||
<ButtonWithIcon
|
<ButtonWithIcon
|
||||||
href={`/notes/${item.id}`}
|
href={`/notes/${item.id}`}
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { printDate } from "../components/utils";
|
import { timestamp2text } from "../components/utils";
|
||||||
import { ChevronDoubleLeftIcon } from "@heroicons/react/24/outline";
|
import { ChevronDoubleLeftIcon } from "@heroicons/react/24/outline";
|
||||||
import { ButtonWithIcon } from "../components/button";
|
import { ButtonWithIcon } from "../components/button";
|
||||||
import { useSearchParams } from "react-router-dom";
|
import { useSearchParams } from "react-router-dom";
|
||||||
|
@ -39,7 +39,7 @@ function PubError() {
|
||||||
{locals.PubError}
|
{locals.PubError}
|
||||||
</h2>
|
</h2>
|
||||||
<div className="justify-self-center lg:justify-self-end">
|
<div className="justify-self-center lg:justify-self-end">
|
||||||
{printDate(Date.now())}
|
{timestamp2text(Date.now())}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="w-full md">{err ? err : locals.PubErrorMsg}</div>
|
<div className="w-full md">{err ? err : locals.PubErrorMsg}</div>
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
import RenderMarkdown from "../components/markdown";
|
import RenderMarkdown from "../components/markdown";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { Navigate, useParams } from "react-router-dom";
|
import { Navigate, useParams } from "react-router-dom";
|
||||||
import { printDate } from "../components/utils";
|
import { timestamp2text } from "../components/utils";
|
||||||
import { ChevronDoubleLeftIcon } from "@heroicons/react/24/outline";
|
import { ChevronDoubleLeftIcon } from "@heroicons/react/24/outline";
|
||||||
import { ButtonWithIcon } from "../components/button";
|
import { ButtonWithIcon } from "../components/button";
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ function PubNote() {
|
||||||
{note.name || "Загрузка..."}
|
{note.name || "Загрузка..."}
|
||||||
</h2>
|
</h2>
|
||||||
<div className="justify-self-center lg:justify-self-end">
|
<div className="justify-self-center lg:justify-self-end">
|
||||||
{printDate(note.time || Date.now())}
|
{timestamp2text(note.time || Date.now())}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="w-full md break-words">
|
<div className="w-full md break-words">
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Navigate } from "react-router-dom";
|
import { Navigate } from "react-router-dom";
|
||||||
import { printDate } from "../components/utils";
|
import { timestamp2text } from "../components/utils";
|
||||||
|
|
||||||
function uuidv4() {
|
function uuidv4() {
|
||||||
return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, (c) =>
|
return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, (c) =>
|
||||||
|
@ -44,7 +44,7 @@ function Save() {
|
||||||
name,
|
name,
|
||||||
text,
|
text,
|
||||||
time,
|
time,
|
||||||
textTime: printDate(time),
|
textTime: timestamp2text(time),
|
||||||
pubTime,
|
pubTime,
|
||||||
pub: !!pubTime,
|
pub: !!pubTime,
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue