3.0.0 ā€¢ Published 12 days ago

@annotation/ng-parse v3.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
12 days ago

Welcome to @annotation/ng-parse šŸ‘‹

Version License: MIT

Angular parsers

šŸ  Homepage

Install

yarn add @annotation/ng-parse
## OR ##
npm install @annotation/ng-parse --save

API

Date parser

functionparametersreturn valuedescription
parseDatevalue: string, format: BasicDateFormat OR string, locale: string, oldValue ?: DateDateFormats value in defined format and locale and returns Date
getDateFormatParserlocale: string, format: BasicDateFormat OR stringDateParserReturns prepared DateParser capable to manually parse given string with DateFormat.parseDate(value, oldValue) method. Also contains DateType[] which helps to identify what parts are in format.
toDatevalue: string OR Date Or numberDateReturns Date from Date, number (timestamp) or ISO string (yyyy-MM-ddTHH:mm:ss:sss)

Examples for date parser functions

  • parseDate
const date: Date = parseDate('01.01.2021', 'dd.MM.yyyy', 'sk')
  • getDateFormatParser
const parser: DateParser = getDateFormatParser('sk', 'dd.MM.yyyy');
const date: Date = parser.parseDate('01.01.2021');
const parts: DateType[] = parser.types;

const hasYear = parts.includes(DateType.FullYear); // true
const hasMinutes = parts.includes(DateType.Minutes) // false
  • toDate
const dateFromMs: Date = toDate(1623926493809);
const dateFromDate: Date = toDate(new Date()); 
const dateFromISO8601_1: Date = toDate('2021-06-16T23:54:08+00:00'); 
const dateFromISO8601_2: Date = toDate('2021-06-16T23:54:08Z'); 

Types for date parsers

type/interfacedefinition
DateTypeFullYear,Month,Date,Hours_24,Hours_12,Minutes,Seconds,FractionalSeconds,DayOfWeek,DayPeriods,Eras,TimeZoneOffset
BasicDateFormatshort', 'medium', 'long', 'full', 'shortDate', 'mediumDate', 'longDate', 'fullDate', 'shortTime', 'mediumTime', 'longTime', 'fullTime'
DatePartFormatsee https://angular.io/api/common/DatePipe#custom-format-options
DateParsererrorMsg: string, types: DateType[], parseDate: (text: string, oldValue?: Date) => Date

Authors

šŸ‘¤ Pavol Slany

  • Website: www.annotation.sk
  • Github: @slany

šŸ‘¤ Martin Filo

  • Website: www.annotation.sk
  • Github: @Chiff

Show your support

Give a ā­ļø if this project helped you!


This README was generated with ā¤ļø by readme-md-generator

3.0.0

12 days ago

2.0.3

1 year ago

2.0.2

1 year ago

2.0.1

1 year ago

2.0.0

1 year ago

1.2.0

2 years ago

1.1.0

3 years ago

1.0.0

3 years ago