Skip to content

Commit

Permalink
fix: date
Browse files Browse the repository at this point in the history
  • Loading branch information
bart-krakowski committed Feb 1, 2023
1 parent 32163b6 commit 4914380
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 3 deletions.
22 changes: 20 additions & 2 deletions packages/p3/code.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
const init = () => __awaiter(this, void 0, void 0, function* () {
figma.showUI(__uiFiles__.main, { width: 400, height: 400 });
});
const months = [
'January',
'February',
'March',
'April',
'May',
'June',
'July',
'August',
'September',
'October',
'November',
'December',
];
figma.ui.onmessage = ({ type, payload }) => {
switch (type) {
case 'change-status':
Expand Down Expand Up @@ -110,9 +124,13 @@ const archive = () => {
}));
const minY = Math.min(...yPositions.map((pos) => pos.y));
const x = Math.min(...yPositions.filter((pos) => pos.y === minY).map((pos) => pos.x));
console.log('isFinite(minY) ? minY - el.height - 400 : 0', isFinite(minY) ? minY - el.height - 400 : 0);
archivePage.appendChild(el);
el.name = `${el.name.replace(/^(🚧||) /, '')} | Archived on ${new Date().toLocaleDateString()}`;
const dateObj = new Date();
const day = dateObj.getDay();
const month = months[dateObj.getMonth()];
const year = dateObj.getFullYear();
const formattedDate = `${month} ${day}, ${year}`;
el.name = `${el.name.replace(/^(🚧||) /, '')} | Archived on ${formattedDate}`;
el.y = isFinite(minY) ? minY - el.height - 400 : 0;
el.x = isFinite(x) ? x : 0;
});
Expand Down
25 changes: 24 additions & 1 deletion packages/p3/code.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,22 @@ type MessageProps =
type: 'archive'
payload: never
}

const months = [
'January',
'February',
'March',
'April',
'May',
'June',
'July',
'August',
'September',
'October',
'November',
'December',
]

figma.ui.onmessage = ({ type, payload }: MessageProps) => {
switch (type) {
case 'change-status':
Expand Down Expand Up @@ -134,7 +150,14 @@ const archive = () => {
const x = Math.min(...yPositions.filter((pos) => pos.y === minY).map((pos) => pos.x))

archivePage.appendChild(el)
el.name = `${el.name.replace(/^(🚧||) /, '')} | Archived on ${new Date().toLocaleDateString()}`

const dateObj = new Date()
const day = dateObj.getDay()
const month = months[dateObj.getMonth()]
const year = dateObj.getFullYear()
const formattedDate = `${month} ${day}, ${year}`

el.name = `${el.name.replace(/^(🚧||) /, '')} | Archived on ${formattedDate}`
el.y = isFinite(minY) ? minY - el.height - 400 : 0
el.x = isFinite(x) ? x : 0
})
Expand Down

0 comments on commit 4914380

Please sign in to comment.