1.1.0 • Published 6 years ago

br-date-helper v1.1.0

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

BR Date Helper

This is a simple Date Formater for Brazilian Date Format.

Installing via NPM

npm install br-date-helper

Using this helper in an Ionic app

// Import the Helper on app.module.ts
import { BrDateHelper } from 'br-date-helper';

@NgModule({
  declarations: [
    // ...
  ],
  imports: [
    // ...
  ],
  entryComponents: [
    // ..
  ],
  providers: [
    BrDateHelper
  ]
})
export class AppModule {}

Once you have imported the helper, you can use it inside your pages like this:

// Import the Helper on your page
import { BrDateHelper } from '../../../node_modules/br-date-helper';

@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {

  constructor(public navCtrl: NavController) {

  }

  whatDayIsIt() {
    console.log(this.brDateHelper.today());
  }

}

Documentation

Methods

Nameparamsreturn
adddays, months, yearsstring
dateDiffgreaterDate, lesserDatestring
todaystring
tomorrowstring
yesterdaystring

Examples

export class HomePage {

  constructor(public navCtrl: NavController, public brDateHelper: BrDateHelper) {

  }

  // Those examples was taken at 07-30-2018
  console.log(this.brDateHelper.yesterday()); //outputs: "29/07/2018"

  console.log(this.brDateHelper.today()); //outputs: "30/07/2018"

  console.log(this.brDateHelper.tomorrow()); //outputs: "31/07/2018"

  console.log(this.brDateHelper.dateDiff(this.brDateHelper.today(), "30/06/2018")); //outputs: {years: 0, months: 1, days: 1}

  console.log(this.brDateHelper.dateDiff(this.brDateHelper.today(), "22/08/1995")); //outputs: {years: 22, months: 11, days: 8}

  console.log(this.brDateHelper.add(3, 3, 1)); //outputs: "02/11/2019"

  console.log(this.brDateHelper.add(-15, 0, -1)); //outputs: "15/7/2017"
}
1.1.0

6 years ago

0.0.14

6 years ago

0.0.13

6 years ago

0.0.12

6 years ago

0.0.11

6 years ago

0.0.10

6 years ago

0.0.9

6 years ago

0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago