Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

clockify

Package Overview
Dependencies
Maintainers
0
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clockify - npm Package Compare versions

Comparing version 0.12.13 to 0.13.0

34

bin/model.js

@@ -371,12 +371,22 @@ "use strict";

const firstEventDate = utils_1.default.getDateObj(resp.data[0].date);
const currentDate = new Date();
const cal = utils_1.default.generateCalendar({
year: firstEventDate.year,
month: firstEventDate.month,
start: {
year: firstEventDate.year,
month: firstEventDate.month,
},
end: {
year: currentDate.getFullYear(),
month: currentDate.getMonth() + 1,
},
});
// console.log({ cal })
console.log({ cal });
resp.data.forEach((event, index, arr) => {
const durationHours = event.duration / 60 / 60;
const eventYearNumber = new Date(event.date).getFullYear();
const eventMonthNumber = new Date(event.date).getMonth() + 1;
const eventDayNumber = new Date(event.date).getDate();
const eventMonthName = utils_1.default.getMonthName(eventMonthNumber);
console.log(eventYearNumber, eventMonthName);
const currentMonth = cal[eventYearNumber][eventMonthName];
// console.log(eventMonthNumber, eventDayNumber, eventMonthName);

@@ -392,15 +402,13 @@ // console.log({

// increment durations
cal[eventMonthName].duration += durationHours;
cal[eventMonthName].days[eventDayNumber - 1].hours += durationHours;
currentMonth.duration += durationHours;
currentMonth.days[eventDayNumber - 1].hours += durationHours;
// calculate total and avg
const isLastEvent = index == arr.length - 1;
const isEndOfMonth = cal[eventMonthName].days.length == eventDayNumber;
const isLastEventInDay = "?";
const isEndOfMonth = currentMonth.days.length == eventDayNumber;
if (isEndOfMonth || isLastEvent) {
console.log({ isEndOfMonth, isLastEvent });
cal[eventMonthName].fullDate =
`${firstEventDate.year}-${eventMonthNumber}`;
cal[eventMonthName].hoursPerDay =
cal[eventMonthName].duration / cal[eventMonthName].days.length;
console.log({ hpd: cal[eventMonthName].hoursPerDay });
// console.log({ isEndOfMonth, isLastEvent });
currentMonth.fullDate = `${firstEventDate.year}-${eventMonthNumber}`;
currentMonth.hoursPerDay =
currentMonth.duration / currentMonth.days.length;
// console.log({ hpd: cal[eventMonthName].hoursPerDay });
}

@@ -407,0 +415,0 @@ });

@@ -193,2 +193,3 @@ "use strict";

}),
// print calendar
p: (socket, request) => __awaiter(void 0, void 0, void 0, function* () {

@@ -208,19 +209,22 @@ const activity = (request === null || request === void 0 ? void 0 : request.args[0]) || timerObj.currentActivity || undefined;

let notifyMsg = "";
Object.entries(resp.data).forEach((month, idx, list) => {
const [monthName, monthData] = month;
if (idx == 0) {
periodString += `from ${monthName}`;
}
else if (idx == list.length - 1) {
periodString += ` to ${monthName}`;
}
monthDurationCounter += monthData.duration;
const monthTitle = `\n${monthName}: ${utils_1.default.secToTimeStr(monthData.duration * 60 * 60)} | ${monthData.hoursPerDay.toFixed(2)} hours per day`;
data += monthTitle;
notifyMsg += monthTitle;
if (monthData.duration > 0) {
monthData.days.forEach((day, index) => {
data += `\n [${index + 1}] ${day.hours.toFixed(2)} hours`;
});
}
Object.entries(resp.data).forEach((year, idx, list) => {
const [yearNumber, monthObj] = year;
Object.entries(monthObj).forEach((month, idx, list) => {
const [monthName, monthData] = month;
if (idx == 0) {
periodString += `from ${monthName}`;
}
else if (idx == list.length - 1) {
periodString += ` to ${monthName}`;
}
monthDurationCounter += monthData.duration;
const monthTitle = `\n${monthName}: ${utils_1.default.secToTimeStr(monthData.duration * 60 * 60)} | ${monthData.hoursPerDay.toFixed(2)} hours per day`;
data += monthTitle;
notifyMsg += monthTitle;
if (monthData.duration > 0) {
monthData.days.forEach((day, index) => {
data += `\n [${index + 1}] ${day.hours.toFixed(2)} hours`;
});
}
});
});

@@ -236,3 +240,2 @@ // adding total hours

var _a;
// todo: get activities list
const resp = yield model_1.default.getActivities({

@@ -239,0 +242,0 @@ socket,

@@ -115,20 +115,41 @@ "use strict";

};
function generateCalendar(start) {
function generateCalendar({ start, end }) {
const calendar = {};
for (let monthNumber = start.month; monthNumber <= 12; monthNumber++) {
let lastDay = new Date(start.year, monthNumber, 0).getDate();
const monthName = new Date(start.year, monthNumber - 1).toLocaleString("default", { month: "long" });
const currentMonthNumber = new Date().getMonth() + 1;
if (currentMonthNumber == monthNumber) {
lastDay = new Date().getDate();
}
calendar[monthName] = {
duration: 0,
hoursPerDay: 0,
fullDate: "",
days: Array.from({ length: lastDay }, (_, i) => ({ hours: 0 })),
};
if (currentMonthNumber == monthNumber) {
let yearCounter = start.year;
let bellowLastYear = Number(yearCounter) <= Number(end.year);
for (;; yearCounter++) {
bellowLastYear = Number(yearCounter) <= Number(end.year);
if (!bellowLastYear) {
break;
}
// @ts-ignore
calendar[yearCounter] = {};
console.log({
yearCounter,
end: end.year,
condition: Number(yearCounter) <= Number(end.year),
condition2: bellowLastYear,
typeofyearcounter: typeof yearCounter,
typeofyearend: typeof end.year,
});
let monthCounter = start.year == yearCounter ? start.month : 1;
const lastMonth = bellowLastYear ? 12 : end.month;
for (; monthCounter <= lastMonth; monthCounter++) {
console.log({ monthCounter, end: end.month });
let lastDay = new Date(start.year, monthCounter, 0).getDate();
const monthName = new Date(start.year, monthCounter - 1).toLocaleString("default", { month: "long" });
const currentMonthNumber = new Date().getMonth() + 1;
if (currentMonthNumber == monthCounter) {
lastDay = new Date().getDate();
}
calendar[yearCounter][monthName] = {
duration: 0,
hoursPerDay: 0,
fullDate: "",
days: Array.from({ length: lastDay }, (_, i) => ({ hours: 0 })),
};
if (currentMonthNumber == monthCounter) {
break;
}
}
}

@@ -135,0 +156,0 @@ return calendar;

{
"name": "clockify",
"version": "0.12.13",
"version": "0.13.0",
"description": "A time tracker to make sure that you really spent the time you think you spent working, studying, etc.",

@@ -5,0 +5,0 @@ "license": "MIT",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc