year-in-percent
v1.0.0
Published
year-in-percent is a lightweight npm package that calculates and displays the percentage of the year that has been completed.
Downloads
15
Maintainers
Readme
Year In Percent
Year In Percent is a lightweight, easy-to-use library that provides the current year's completion percentage. It calculates the percentage of the year that has passed based on the current date and time. Perfect for adding a touch of progress tracking to your apps, websites, or projects!
Features
- Calculate the percentage of the current year that has been completed.
- Lightweight and easy to integrate.
- Returns a JSON object with the percentage, current date, start of the year, end of the year, total milliseconds in the year, and milliseconds elapsed in the year.
Installation
You can install the package via npm:
npm install year-in-percent
Usage
Here's how to use the Year In Percent in your project:
import { CalculateYearCompletionPercentage } from 'year-in-percent';
// Create an instance of the calculator
const yearCompletion = new CalculateYearCompletionPercentage();
// Get the current year completion percentage
const result = yearCompletion.getYearCompletionPercentage();
console.log(result);
console.log(`Year completion: ${result.percentageCompleted}%`);
Methods
getYearCompletionPercentage()
Returns a JSON object with the following properties:
percentageCompleted
: Astring
representing the percentage (e.g.,"75.08"
).now
: Adate
object representing the current date and time.startOfYear
: Adate
object representing the start of the current year.endOfYear
: Adate
object representing the end of the current year.totalMillisecondsInYear
: Anumber
representing the total milliseconds in the current year.millisecondsElapsedInYear
: Anumber
representing the milliseconds elapsed since the start of the year.
Example Response:
{
"percentageCompleted": "75.08",
"now": "2024-10-01T18:35:52.654Z",
"startOfYear": "2024-01-01T00:00:00.000",
"endOfYear": "2024-12-31T23:59:59.000Z",
"totalMillisecondsInYear": 31622399000,
"millisecondsElapsedInYear": 23740552654
}
Setup on Your Local Machine
To set up the project on your local machine, follow these steps:
Clone the repository:
git clone [email protected]:evrentan/year-in-percent.git
Navigate to the project directory:
cd year-in-percent
Install the dependencies:
npm install
Build the project:
npm run build
Test the project:
npm test
Contributing
Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create your feature branch (
git checkout -b feature/yourFeature
). - Commit your changes (
git commit -m 'feat(Feature): Add some Feature'
). - Push to the branch (
git push origin feature/yourFeature
). - Open a pull request.
License
This project is licensed under the ISC License.
About
This library was created to help developers easily calculate the progress of the current year. If you have any questions or suggestions, feel free to reach out!
Sponsoring
If you enjoy this project and would like to support its development, please consider sponsoring. Your support helps me continue improving and maintaining the project.
You can sponsor me via:
Thank you for your support!