Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Input format not working as expected. #2435

Closed
Anzil-Aufait opened this issue Nov 17, 2021 · 8 comments
Closed

Input format not working as expected. #2435

Anzil-Aufait opened this issue Nov 17, 2021 · 8 comments

Comments

@Anzil-Aufait
Copy link

I want to change date format to 'MMM, DD, YYYY', but i can't find a way to do that.

I'm using tempus-dominus@6.0.0-alpha1.0.4 veersion. But when I use this version tempus-dominus@master it's working fine. There is problem with Master version, that it will not change position based on the screen resize.

tempus-dominus@6.0.0-alpha1.0.4: This is the stackblitz code.
tempus-dominus@master: This is the stackblitz code.

Please check.

@tygrysio
Copy link

tygrysio commented Nov 17, 2021

I do it like this.
inputFormat: (context, date) => { var formatter = new Intl.DateTimeFormat('pl-PL', { year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit' }); var dateTable = formatter.formatToParts(date); //alert(JSON.stringify(dateTable)); return dateTable[4].value + '-' + dateTable[2].value + '-' + dateTable[0].value + ' ' + dateTable[6].value + ':' + dateTable[8].value; }

@Eonasdan
Copy link
Owner

@Anzil-Aufait there was a breaking change in alpha14 for input format it should be inputFormat: (context, date)

If you change your second example to something like this it should work.

hooks: {
      inputFormat: (context, date) => {
      return moment(date).format('MMM, DD, YYYY')
      }
    }

@Anzil-Aufait
Copy link
Author

Anzil-Aufait commented Nov 17, 2021

@Anzil-Aufait there was a breaking change in alpha14 for input format it should be inputFormat: (context, date)

If you change your second example to something like this it should work.

hooks: {
      inputFormat: (context, date) => {
      return moment(date).format('MMM, DD, YYYY')
      }
    }

@Eonasdan Hi, thank you for the replay.

Currently i'm using tempus-dominus@6.0.0-alpha1.0.4 veersion.

hooks: {
  inputFormat: (context, date) => {
    return moment(date).format('MMM, DD, YYYY')
  }
}

Above format is not working in this version. Is it possible you to check this link and please provide a working code to change the format to 'MMM, DD, YYYY'.

@Eonasdan
Copy link
Owner

Eonasdan commented Nov 18, 2021

Why do you want to use an old alpha? Why not upgrade?

That version takes an Intl format e.g. { month: 'short' ... }. That's why it's a function now so you can customize it more.

@Anzil-Aufait
Copy link
Author

@Eonasdan Is it possible to share latest CDN link here?

@Eonasdan
Copy link
Owner

Eonasdan commented Nov 18, 2021

Of course

<script src="https://cdn.jsdelivr.net/gh/Eonasdan/tempus-dominus@master/dist/js/tempus-dominus.js"></script>

<link
  href="
https://cdn.jsdelivr.net/gh/Eonasdan/tempus-dominus@master/dist/css/tempus-dominus.css"
  rel="stylesheet"
/>

This will point to the latest code. If you prefer to be locked into a release you can exchange master with v6.0.0-alpha14 in the code above

@Anzil-Aufait
Copy link
Author

Of course

<script src="https://cdn.jsdelivr.net/gh/Eonasdan/tempus-dominus@master/dist/js/tempus-dominus.js"></script>

<link
  href="
https://cdn.jsdelivr.net/gh/Eonasdan/tempus-dominus@master/dist/css/tempus-dominus.css"
  rel="stylesheet"
/>

This will point to the latest code. If you prefer to be locked into a release you can exchange master with v6.0.0-alpha14 in the code above

@Eonasdan Thank you for the update. Now it is working fine.

But i notice a missing feature with Latest version that is master. In this v6.0.0-alpha14 version the picker widget will change it's position based on available space.

@Anzil-Aufait Anzil-Aufait reopened this Nov 18, 2021
@Eonasdan
Copy link
Owner

The picker will either display on "top" or "bottom" of whatever element you attached it to. If this is not working for you please provide a screen capture or a stackblitz.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants