techouse / intl-date-time

International DateTime for Laravel Nova
MIT License
57 stars 21 forks source link

Show time without need to format it #24

Closed henryavila closed 4 years ago

henryavila commented 4 years ago

If I use the code (locale: pt-br): IntlDateTime::make('Data', 'created_at') I will get a Date Field (no time is displayed).

If I use the TimeFormat function: IntlDateTime::make('Data', 'created_at')->timeFormat('HH:mm:ss') the time is displayed but I don't have a way to display the time without defining it format.

I would be perfect if I can enable to show the time and the app get the current locale to format the time.

techouse commented 4 years ago

I have thought about this when I initially wrote the plugin but since there's basically 2 ways of the defining the time: HH:mm (short) and HH:mm:ss (long). At the time I simply decided to leave it up to the user to define their own time. However, I could make 2 additional options for the default locale's time in short and long format.

henryavila commented 4 years ago

Thanks @techouse and congratulation for the great plugin. It saved my life. The native field is completly broken for international use.

techouse commented 4 years ago

Added in v1.5.3.

Here's an excerpt from the readme

<?php
            DateTime::make(__('Time of arrival'), 'time_of_arrival')
                    /**
                     * Shortcut for displaying the full locale time, e.g. HH:mm:ss.
                     * 
                     * NOTE: The timeFormat option has precedence over withTime.
                     */
                    ->withTime(),

            DateTime::make(__('Time of reservation'), 'time_of_reservation')
                    /**
                     * Shortcut for displaying the short locale time, e.g. HH:mm.
                     * 
                     * NOTE: The timeFormat option has precedence over withTimeShort.
                     */
                    ->withTimeShort(),