transloco icon indicating copy to clipboard operation
transloco copied to clipboard

Feature: Get current date format

Open PeterHewat opened this issue 3 years ago • 0 comments

Is your feature request related to a problem? Please describe.

I am using transloco & transloco-locale with PrimeNG. When I use a their calendar, I want the date to be displayed in the current format transloco-locale is using. The problem is that all I have access to in the calendar is the dateFormat attribute which enables me to manually specify a date format (ex: "dd.mm.yy").

Describe the solution you'd like

I'd like to be able to get the current date format from transloco-locale to be able to feed it to the calendar.

Describe alternatives you've considered

A better alternative would be for PrimeNG's calendar to natively use transolo-locale for formatting but I'm not sure this is feasible.

Current behavior

No way to get the current format from transloco-local

Expected behavior

import { Component, OnInit } from '@angular/core';
import { TranslocoLocaleService } from '@ngneat/transloco-locale';

@Component({
  selector: 'app-test',
  templateUrl: './test.component.html',
  styleUrls: ['./test.component.scss'],
})
export class TestComponent implements OnInit {
  constructor(private translocoLocale: TranslocoLocaleService) {}
  ngOnInit() {
    console.log(this.translocoLocale.getDateFormat({dateStyle: 'short'}));
    // outputs => MM/DD/YYYY
  }
}

PeterHewat avatar Mar 18 '21 08:03 PeterHewat