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

24-Hour Military Time #11

Open
acutemedical opened this issue Mar 6, 2015 · 12 comments
Open

24-Hour Military Time #11

acutemedical opened this issue Mar 6, 2015 · 12 comments

Comments

@acutemedical
Copy link

We should have the option in time_select to use military time 00:00-23:59 instead of the standard AM/PM format. I'm thinking about monkey patching this, but it would probably be best if I worked on a PR unless you've already a way to do this quickly.

@acutemedical
Copy link
Author

Using :ampm => false should yield a 24-hour/military time scope, but it doesn't work.

@excid3
Copy link
Owner

excid3 commented Mar 6, 2015

I don't think I have a way of doing that at the moment.

I'd love to see that too. 👍

@acutemedical
Copy link
Author

Ok, I'll fork it and work on a PR that solves this problem. I may even write a test or two. (Surprise!)

@excid3
Copy link
Owner

excid3 commented Mar 6, 2015

If you get into some trouble with it, we might just want to rewrite the gem from scratch. It's probably easier to generate a select tag for both and then write a method in the controller to transform it to a Time. Seems like that would be a better solution than how this is currently designed.

@acutemedical
Copy link
Author

I've actually considered rewriting the gem from scratch. I think there's a simpler way to parse datetime into a combined object. I may need some help with some of the "features" but the core functionality of combining date/time together I have something up my sleeve.

@excid3
Copy link
Owner

excid3 commented Mar 6, 2015

I'm open to it. Want to prototype something in a branch and we can see how to move forward?

@acutemedical
Copy link
Author

Yes, I'd like that. I have a few different ideas on how to simplify the gem's codebase.

@excid3
Copy link
Owner

excid3 commented Mar 6, 2015

:shipit:

Send me a link to your branch when you've got a draft. I'm excited to see what you come up with!

@acutemedical
Copy link
Author

Will do. I plan to work on this sometime this weekend when I'm back.

@nynhex
Copy link

nynhex commented Jul 15, 2015

I still need to figure this out. I am working on an app where I need military time. Any thoughts on where I can start in the code?

@nynhex
Copy link

nynhex commented Jan 31, 2016

@excid3 I totally forgot about this. I forked this into a branch and am going to refactor it to accept 24:00 format. As soon as I have it working, I'll make a PR against master. What would be the best way to test this? I can write some rspec or minitest but I'm thinking of just bootstrapping a simple rails app and browser/controller testing. Thoughts?

@nynhex
Copy link

nynhex commented Jan 31, 2016

@excid3 after forking this branch and testing it out against different rails versions I got the 24:00 military time to work. Looks like this wasn't working in the original version which I was locked at. So I upgraded, and here's the code that gets it to work in 24:00/Military.

<%= f.date_select :due_date, order: [:month, :day, :year] %>
  <%= f.time_select :due_date,
              :combined => true,
              :default => Time.zone.now,
              :minute_interval => 15,
              :time_separator => "",
              :start_hour => 00,
              :end_hour => 23,
              :labels => false,
              :ampm => false %>

Looks like the labels and ampm options have to be set to false. You can close this issue.

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