Skip to content

Commit

Permalink
move convertDateToRRuleDate outside lib
Browse files Browse the repository at this point in the history
  • Loading branch information
aldabil21 committed Feb 26, 2025
1 parent 2e5ad03 commit c6a360a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 25 deletions.
13 changes: 11 additions & 2 deletions src/events.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { RRule } from "rrule";
import { datetime, RRule } from "rrule";
import { ProcessedEvent } from "./lib/types";
import { convertDateToRRuleDate } from "./lib/helpers/generals";

export const EVENTS: ProcessedEvent[] = [
{
Expand Down Expand Up @@ -204,3 +203,13 @@ export const generateRandomEvents = (total = 300) => {

return events;
};

function convertDateToRRuleDate(date: Date) {
return datetime(
date.getFullYear(),
date.getMonth() + 1,
date.getDate(),
date.getHours(),
date.getMinutes()
);
}
11 changes: 0 additions & 11 deletions src/lib/helpers/generals.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import {
SchedulerProps,
} from "../types";
import { StateEvent } from "../views/Editor";
import { datetime } from "rrule";

export const getOneView = (state: Partial<SchedulerProps>): View => {
if (state.month) {
Expand Down Expand Up @@ -126,16 +125,6 @@ export const differenceInDaysOmitTime = (start: Date, end: Date) => {
return differenceInDays(endOfDay(addSeconds(end, -1)), startOfDay(start));
};

export const convertDateToRRuleDate = (date: Date) => {
return datetime(
date.getFullYear(),
date.getMonth() + 1,
date.getDate(),
date.getHours(),
date.getMinutes()
);
};

export const convertRRuleDateToDate = (rruleDate: Date) => {
return new Date(
rruleDate.getUTCFullYear(),
Expand Down
14 changes: 2 additions & 12 deletions vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import dts from "vite-plugin-dts";
import tsconfigPaths from "vite-tsconfig-paths";
import { peerDependencies } from "./package.json";
import peerDepsExternal from "rollup-plugin-peer-deps-external";

const __dirname = dirname(fileURLToPath(import.meta.url));

Expand All @@ -15,6 +15,7 @@ export default defineConfig(() => ({
configNames: ["tsconfig.json"],
}),
dts({ tsconfigPath: "./tsconfig.build.json" }),
peerDepsExternal(),
],
server: {
port: 3000,
Expand All @@ -31,17 +32,6 @@ export default defineConfig(() => ({
name: "Scheduler",
formats: ["es"],
},
rollupOptions: {
external: (path) => {
const nodeModules = path.includes("node_modules");
const isPeer = Object.keys(peerDependencies).some((dep) => path.startsWith(dep));
const isExternal = nodeModules || isPeer;
return isExternal;
},
output: {
globals: (path) => path,
},
},
copyPublicDir: false,
},
resolve: {
Expand Down

0 comments on commit c6a360a

Please sign in to comment.