Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
ng-datefns-pipes
Advanced tools
Angular pipes based on date-fns. Date pipe, time-ago pipe, minDate pipe, maxDate pipe, distanceBetweenDates pipe.
Angular pipes based on date-fns. Date pipe, time-ago pipe, minDate pipe, maxDate pipe, distanceBetweenDates pipe. I initially built these for Ionic projects, because the Angular date pipe was performing poorly on some mobile devices, and the date-fns functions were not exhibiting problems. However, no use of Ionic is required. This npm library should work with any Angular 5 project, and any Ionic 3 project.
npm install ng-datefns-pipes --save
Date pipe:
napoleon = new Date(1804, 11, 2); // in ts file
Napoleon crowned himself emperor on {{ napoleon | date }}. // in template
Napoleon crowned himself emperor on December 2nd, 1804. // output
Time ago pipe:
aquinas = new Date(1274, 2, 7); // in ts file
Aquinas died {{ aquinas | ago }}.<br> // in template
Aquinas died almost 744 years ago. // output
Time ago pipe second example:
now = new Date(); // in ts file
You entered this page {{ now | ago }}. // in template
You entered this page less than 5 seconds ago. // output (updates every 15 seconds)
Distance between dates:
datePair = [ this.aquinas, this.napoleon ]; // in ts file
Aquinas's and Napoleon's actions were separated by {{ datePair | distanceBetweenDates }}. // in template
Aquinas's and Napoleon's actions were separated by almost 531 years. // output
Min date:
dateArray = [ this.aquinas, this.napoleon, this.now ]; // in ts file
The earliest of those dates is {{ dateArray | minDate }}. // in template
The earliest of those dates is March 7th, 1274. // output
Max date:
The most recent of those dates is {{ dateArray | maxDate }}. // in template (ts file same as before)
The most recent of those dates is ___. // <-- output, blank contains today's date
In app.module.ts
:
import { DatePipesModule } from 'ng-datefns-pipes';
@NgModule({
declarations: [],
imports: [
DatePipesModule.forRoot() // < -- add this line
],
bootstrap: [],
entryComponents: [],
providers: []
})
export class AppModule {}
This gives you access to all the (English language) date pipes, with the default configuration. For details, see the API below.
You can specify a default date format; whether date distance functions include seconds; and the prefix, suffix, refresh rate and use of seconds of the timeAgo pipe. (For more detail about these settings, see the API below. You can also set and reset each setting during the program by injecting the DatePipeManager.)
In app.module.ts
:
import { DatePipesModule, DatePipeConfiguration } from 'ng-datefns-pipes';
const DATE_PIPE_CONFIG: DatePipeConfiguration = {
defaultDateFormat: 'your date format string', // default: 'MMMM Do, YYYY'
dateDistanceIncludesSeconds: your boolean here, // default: false
agoPipeOptions: {
refreshRate: your milliseconds here, // default: 15000
prefix: 'your prefix string', // default: ''
suffix: 'your suffix string', // default: ' ago' <-- note the space
includeSeconds: your boolean here // default: false
}
}
@NgModule({
declarations: [],
imports: [
DatePipesModule.forRoot(DATE_PIPE_CONFIG) // < -- add this line
],
bootstrap: [],
entryComponents: [],
providers: []
})
export class AppModule {}
FAQs
Angular pipes based on date-fns. Date pipe, time-ago pipe, minDate pipe, maxDate pipe, distanceBetweenDates pipe.
The npm package ng-datefns-pipes receives a total of 1 weekly downloads. As such, ng-datefns-pipes popularity was classified as not popular.
We found that ng-datefns-pipes demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.