@jmjhox/date-simplify
v3.0.2
Published
<div id="top"></div>
Downloads
14
Maintainers
Readme
About The Project
There are many great libraries to calculate time & dates and often they offer you a set of tools that lets you build your code, but sometimes your are struggling to find that specific function that do what you wants to do in your code while you trying to write the less code possible or not to spend too much time on it. Keep it simple!
That´s WHY you should start using Date-Simplify instead! or at least give it a try
Built With
Getting Started
Prerequisites
- npm
npm install @jmjhox/date-simplify
- Javascript/Typescript project to integrate our library
Installation
We only have to import "DateSimplify" into our proyect like a dependency:
import { dateSimplify } from '@jmjhox/date-simplify'
Below it is a example of how you import it to your component.ts using Angular 13:
import { Component, OnInit } from '@angular/core';
import { dateSimplify } from '@jmjhox/date-simplify'
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent implements OnInit{
constructor(){}
ngOnInit(): void
{
dateSimplify.dateFormat('12/12/1998')
}
}
Usage
getAgeLimitOnUTC
Is a method used to get the age limit of the user based on the actual date of the year or a custom date you want to use it from reference using UTC
How to use it
It has two parameters:
getAgeLimitOnUTC(dateRange: number, ChangeDate?: string)
dateRange: number(the number you want to limit)
ChangeDate?: string (the date you migh want to use from reference, the format is dd/mm/yyyy)
getAgeLimitOnLocal
Is a method used to get the age limit of the user based on the actual date of the year or a custom date you want to use it from reference using your local time
How to use it
It has two parameters:
getAgeLimitOnLocal(dateRange: number, ChangeDate?: string)
dateRange: number(the number you want to limit)
ChangeDate?: string (the date you migh want to use from reference, the format is dd/mm/yyyy)
dateFormat
Is a method that formats any kind of date to the want desired for the user, if for some reasons, the date is impossible to get, it returns the same date introduced.
Structure
dateFormat(
dateRequest: string,
formatStyle: string)
dateRequest is the date introduced on string format. it is a experimental feature, for now this kind of format is permitted to be used: 02-23-1998 02/23/1998 02231998
formatStyle is the type of date you want to be returned or formatted, this is a list of formats you migh want to use: ddMMyyyy dd-MM-yyyy dd/MM/yyyy ISO UNIX
Take in consideration that some formats as ddMMyyyy, dd-MM-yyyy and ISO returns a string on response using this function, meanwhile UNIX format returns a number on response. Formats like dd.MM.yyyy , MM.dd.yyyy and other kind, we are working to this combinations be implemented on our next release, for now it is not being supported.
How to use it
ddMMyyyy
dateSimplify.dateFormat('02-23-1998', 'ddMMyyyy')
It should Return 02231998 on string format.
dd-MM-yyyy
dateSimplify.dateFormat('02-23-1998', 'dd-MM-yyyy')
It should Return 02-23-1998 on string format.
ISO
dateSimplify.dateFormat('02-23-1998', 'ISO')
It should Return 1998-02-23T05:00:00.000Z on string format.
UNIX
dateSimplify.dateFormat('02-23-1998', 'UNIX')
It should Return 888192000000 on number format.
unixFormat
Is a method that formats any kind of date to the want desired for the user, using UNIX format to be handled.
Structure
unixFormat(
dateRequest: number,
formatStyle: string)
dateRequest is the date introduced on string format. it is a experimental feature, for now this kind of format is permitted to be used: 1648313180
formatStyle is the type of date you want to be returned or formatted, this is a list of formats you migh want to use: ddMMyyyy dd-MM-yyyy dd/MM/yyyy
dateIsValid
method to check if a date is valid or not. it only returns false or true.
How to use it
dateSimplify.dateIsValid('12','12','1998')
It should Return 12/12/1998 on string format
dateIsValidFix
Checks if the date is valid, and attempts to fix the date automatically for yourself
Format:
dateSimplify.dateIsValidFix(day: string, month: string, year: string)
How to use it
dateSimplify.dateIsValidFix('12','12','1998')
It should Return 12/12/1998 on string format
For more examples, please refer to the Documentation
Roadmap
- [x] Add Changelog
- [x] Add back to top links
- [ ] Add Additional Templates w/ Examples
- [ ] Add "components" document to easily copy & paste sections of the readme
- [ ] Multi-language Support
- [ ] Chinese
- [ ] Spanish
See the open issues for a full list of proposed features (and known issues).
Contributing
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
License
Date-Simplify is distributed under the MIT License.
Contact
JMJHOX - [email protected]
Project Link: https://github.com/JMJHOX/date-simplify
Code of Conduct
In order to ensure that the Date-simplify community is welcoming to all, please review and abide by the Code of Conduct.
Security Vulnerabilities
If you discover a security vulnerability within Date-simplify, please send an e-mail to Jose Aparicio via [email protected]. All security vulnerabilities will be promptly addressed.