Skip to content

Commit

Permalink
fix: isolike date time in branch_name field (openfoodfacts#531)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheHosterParis committed Sep 26, 2024
1 parent 3077bae commit a4804ea
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
1 change: 1 addition & 0 deletions taxonomy-editor-frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions taxonomy-editor-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"@yaireo/dragsort": "^1.3.1",
"@yaireo/tagify": "^4.17.9",
"axios": "^1.6.7",
"date-fns": "^4.1.0",
"fast-deep-equal": "^3.1.3",
"iso-639-1": "^2.1.15",
"react": "^18.2.0",
Expand Down
13 changes: 3 additions & 10 deletions taxonomy-editor-frontend/src/pages/startproject/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { format } from "date-fns";
import { useEffect, useState, useCallback } from "react";
import { useNavigate } from "react-router-dom";

Expand All @@ -22,16 +23,8 @@ import { createBaseURL, toSnakeCase } from "@/utils";

const branchNameRegEx = /[^a-z0-9_]+/;

function formatDate(date) {
const map = {
mm: ("0" + (date.getMonth() + 1)).slice(-2),
dd: ("0" + date.getDate()).slice(-2),
yy: ("0" + date.getFullYear()).slice(-2),
HH: ("0" + date.getHours()).slice(-2),
MinMin: ("0" + date.getMinutes()).slice(-2),
};

return `${map.mm}${map.dd}${map.yy}_${map.HH}_${map.MinMin}`;
function formatDate(date: Date): string {
return format(date, "yyMMdd_HH_mm");
}

export const StartProject = () => {
Expand Down

0 comments on commit a4804ea

Please sign in to comment.