jquery mobile datebox iterating through the shown dates - jquery-mobile

I am using the jquery mobile datebox at http://dev.jtsage.com/jQM-DateBox2/demos/fullopt.html In particular I am using the calbox option at http://dev.jtsage.com/cdn/datebox/1.1.0/jqm-datebox-1.1.0.mode.calbox.js
How can I iterate through all days shown on the calendar and get the date in the format "YYYY-MM-DD"? It is easy to get the day only since that is being shown so you can extract it from the dom - but is their a way to get the year and the month portion as well?
Thanks!

you could look at
$('element').datebox('getTheDate')
but that would give you an incorrect month/year for the "other" months dates. What's your intended purpose, maybe there is a better way to go about it? (Or, if you have a compelling use case, maybe it's something that needs to be added...)

Related

Trying to get this spreadsheet to highlight cells based on todays date

So, I'm looking for a way to make the cell(s) highlight themselves based on todays date, nothing too fancy just so it's simpler to see the day. Pictured below is the graph I currently have.
What I've got
I know it'd be easier for the formula if I were to just format the date as mm/dd/yy or some form of that, but it works better visually for the purpose of the form if it is done this way. So is there a way I could make it work how it is now? If not then what would be best with the formatting done in a mm/dd/yy format? Thank you in advance :)
Use this custom CF formula rule-
=AND(A1=DAY(TODAY()),A$2=TEXT(TODAY(),"MMMM"))
try on range A2:Z:
=A$2&A3=TEXT(TODAY(); "mmmmd")

Selecting date and time with a datepicker for the date but with time immediately visible in Rails

I'm using Rails 4, and also Twitter Bootstrap.
I'd like to select the date with a date picker, but have a separately visible component for selecting the hour and minutes.
I've had a look at smalot bootstrap-datetimepicker https://github.com/smalot/bootstrap-datetimepicker , but looking at the Demo Page, they don't demonstrate any ability to show date and time separately. You have to choose date, and then later on choose time, which doesn't feel very intuitive.
I've also looked at Eonasdan bootstrap-datetimepicker https://github.com/Eonasdan/bootstrap-datetimepicker , but the time picking for it, even in inline mode, is not intuitive - will people know they can just click on the hour value to change it?
I'm thinking of just using a date picker for picking the date, and selecting the hour and minute myself, but it kind of feels wrong handing off part of a datetime to a gem/library and handling the rest of it myself.
I came across Separate date and time form fields in Rails , which is asking about this kind of problem, but it's a question from September 2010.
How do I select the date with a date picker, but have simple and immediately visible selection of time?
First, unless you find a plugin that does what you want off the rack, then yes, it's up to you to handle it, and yes, it feels kinda wrong - depending on how you do it.
Not sure what you had in mind, but the way it feels "the most wrong" is if your form has a single "date time" field under the hood, and you use javascript to botch together the date from the plugin and the time from your own setup, and store them in your datetime field. The nice thing about this is your rails app just gets a single datetime field and knows exactly what to do with it.
Here's how I'd approach it:
Keeping in mind that forms don't necessarily have to map 1-to-1 with your models, I'd split it in the controller layer, and conceptually think of "a form with two fields: date, and time", and then in your controller (or a form object, which is probably better for this situation) you'd stitch the date and time together, before saving them to your model. This approach means you can have separate validation on each field, which is probably also what you want (because I'd assume it's possible for users to input a valid date, but an invalid time or vica versa).
In terms of handling the date with a plugin and the time yourself, that's now fine - they're two completely separate fields from the perspective of your form, so there's nothing dirty about it. It just means you need the extra logic in your controller layer to split the datetime when you display the form, and merge the date and time back into one when you save the form.
Edit: if you haven't heard of form objects, check out https://github.com/apotonick/reform and http://railscasts.com/episodes/416-form-objects

Dygraphs timestamp with timezone

I know there was a lot of discussion about datetime parsing in dygraphs and problems with Javascript. But still, I have a problem how to correctly pass datetime.
I'm using dygraph to show data (points with 5 seconds interval) and it's crucial to have correct datetime. But if I pass datetime as timestamp (1401580800) or as ISO 8601 (2014-06-01T00:00:00+00:00), I always get datetime modified to my local time.
My question is, how to correctly pass the datetime to dygraph so datetime doesn't change?
Dygraphs use Javascript Dates, which display according to your local timezone (unfortunately, there's no way to display them using an arbitrary timezone).
One solution is to modify the data - I've encountered a similar problem in my own work, and I made a small helper function to make fake Javascript UTC dates (basically ending up with a Javascript date that's actually the wrong time but shows up looking correct when displayed in local time). This worked for my application, which used moments (http://momentjs.com/) to represent dates everywhere unless required by some other library to use Javascript's Dates.
Another (probably more correct) solution is to modify Dygraph's functions to display the right things, as demonstrated in the answer to this post: Dygraph showing dates in an arbitrary Timezone
The JavaScript Date object will always use the local time of the computer it's running on. If you don't want that behavior, you'll need to use something else. Consider building a pre-formatted string using something like moment.js and then just pass the string to dygraphs instead of the date.

Excel filter groups some dates but not others

This may be a dumb question with an obvious answer but i can not find or figure out a solution. So I have an excel sheet with 5 tabs, each tab with different data. I've added a filter on the tabs and with some of the date fields it groups by date (you can choose year and month) when you select the drop down. But on others it doesn't. How can i get it to give this grouping option on all of the dates????
Thanks
my best guess is that all the dates in the other tabs might be stored as text and if so, you can convert them back to the date format by copying 1 and pasting as Multiply (Paste Special > Multiply) to all the dates.

Is there a time_from_now gem?

I'm looking for something that given a date, will display the time from now in words. Example:
if today is 4/28/2012, I want:
4/29 to display "Tomorrow"
4/30 to display "Next Monday"
4/31 to display "Next Tuesday"
Is there a gem for this already or do I have to write it myself? If I have to write it what's the cleanest way to do it? I haven't written anything like this before in rails. Thanks!
I believe you're looking for the distance_of_time_in_words helper, which is already available in Rails - it's basically the opposite of time_ago_in_words, in the sense that it tells you the amount of time between two times, as opposed to how long since a certain time has passed vs now, and can therefore be used to measure into the future instead of into the past.
It won't give you days of the week like "Next monday", but if you click the Source: show link at the bottom of the helper's documentation, it will provide you the code you'd need to create a modified version of the helper that could display the day of week information pretty easily. Combine that with the code in this answer regarding calculating the day of the week, and you're pretty much done.

Resources