expiresin
    TypeScript icon, indicating that this package has built-in type declarations

    2.3.4 • Public • Published

    expires-in

    This Angular Module allows you to generate a expiry date. Provide the expiry time length and the start date and it will add the expiry time to the provided date giving you expires in as epoch.

    Installation

    npm install expiresin
    

    Scaffolding

    Import the module into your project under imports

    imports: [
        BrowserModule,
        AppRoutingModule,
        ExpiresInModule
      ],
    

    Use

    In your component file, import the module in the constructor

    private expiresIn: ExpiresIn
    

    Create a time span Model: TimeSpan(seconds, minutes, hours, days, months, years) All are optional.

    const ts = new TimeSpan(0, 30, 2) //2.5 hours
    

    Then call any of the functions, like the example below

    const ts = new TimeSpan(0, 30, 2)
    this.expiresIn.getExpiryTime(ts)
    

    ExpiryDate will be based on NOW as default You can provide a Date Object

    const ts = new TimeSpan(0, 30, 2) //2.5 hours
    const myDate = new Date(2022, 8, 12, 8, 0, 0, 0)
    const exp = this.expiresIn.getExpiryTime(ts, myDate)
    

    Returns

    { expiresIn: 9000, expires: 1640569229 }
    

    Here is a sample of a component setup

    export class AppComponent implements OnInit {
    
      constructor(
        private expiresIn: ExpiresIn
        ) {}
    
      ngOnInit() {
    
        const ts = new TimeSpan(0, 30, 2)
        const exp = this.expiresIn.getExpiryTime(ts)
        console.log(exp)
    
      }
    
    }
    
    

    Install

    npm i expiresin

    DownloadsWeekly Downloads

    39

    Version

    2.3.4

    License

    ISC

    Unpacked Size

    42.7 kB

    Total Files

    20

    Last publish

    Collaborators

    • wavecoders