twinssbc / Ionic-Calendar

A calendar directive for Ionic framework
http://twinssbc.github.io/Ionic-Calendar/demo
MIT License
159 stars 73 forks source link

Time format #18

Open fonini opened 8 years ago

fonini commented 8 years ago

Hi, first of all, thanks for your awesome work!

In the week and day modes, the time on the left column appears like 8am, 9pm etc. But here in Brazil we use 8 and 21, respectively.

Is there a way to show the time based on locale? I'm using the Brazilian locale and month and day names are automatically translated.

twinssbc commented 8 years ago

@fonini Currently the hour column in the week and day view does not have the formatter applied. It uses below logic to generate the content. If you only want to support Brazilian locale, you can directly modify the logic. But I think your requirement is valid, I will add a customizable formatter.

<td class="calendar-hour-column text-center">
       {{::$index<12?($index === 0?12:$index)+'am':($index === 12?$index:$index-12)+'pm'}}
</td>
twinssbc commented 8 years ago

@fonini I have made the hour column accept a date formatter (formatHourColumn), by default the value is 'ha'. The change is included in 0.1.8 version. Feel free to have a try.

fonini commented 8 years ago

@twinssbc Worked like a charm! Thank you so much! p.s.: Any plans to merge the step branch into master? It would be great.

twinssbc commented 8 years ago

@fonini yes, I will merge the step branch into master, it's on my list.

raphaelgodoi commented 8 years ago

@fonini Conseguiu traduzir as outras strings de alguma forma??? Sun, Mon, etc...

fonini commented 8 years ago

Importei o arquivo de locale pt-BR e traduziu tudo automaticamente Em 09/02/2016 20:10, "raphagodoi" notifications@github.com escreveu:

@fonini https://github.com/fonini Conseguiu traduzir as outras strings de alguma forma??? Sun, Mon, etc...

— Reply to this email directly or view it on GitHub https://github.com/twinssbc/Ionic-Calendar/issues/18#issuecomment-182102046 .

raphaelgodoi commented 8 years ago

@fonini Que arquivo? kkk não vi nada disso no projeto, ou eu estou louco ou não sei..

fonini commented 8 years ago

haha...Sem problemas. É um arquivo do Angular mesmo.

https://github.com/angular/angular.js/blob/master/src/ngLocale/angular-locale_pt-br.js

raphaelgodoi commented 8 years ago

Ahhh Deu certinho, muito obrigado jovem!

twinssbc commented 8 years ago

@fonini The step branch has been merged to master, it's included in version 0.2.0.

TomCosta commented 8 years ago

Eu ainda não entendi como fazer isto funcionar num template normal... Alguma dica para instalar? Valeu!

Shounak17 commented 8 years ago

@twinssbc can the time format be changed for month-view ? I want to display the event time in the 12-hr format. Currently displays 01:00 - 21:00. I want to display 01:00 am - 09:00 pm. And also can I add the events in the calendar in the 12-hr format ? Thanks.

twinssbc commented 8 years ago

@Shounak17 Currently the month view doesn't support the customisation of event detail list. As you can see the below code in month.html, I hard coded the time format to be 'HH:mm'. If you want to change it, you have to fork my repository and change it by yourself. But it's a valid requirement, I will expose this format option later.

The calendar itself doesn't care how you add and store your event. As long as when you pass the event to the calendar, the startTime and endTime are valid JS date object.

<td ng-if="!event.allDay" class="monthview-eventdetail-timecolumn">{{::event.startTime|date: 'HH:mm'}}
       -
      {{::event.endTime|date: 'HH:mm'}}
</td>
twinssbc commented 8 years ago

I have added view customisation support in version 0.3.0. It now supports passing the customised template for the event cell in month/week/day view and event detail list in the month view