DatePicker: How do I make my jibberish work: [[ ( 03/01/2018 ).getDayOfWeek()]]

Hi Axure-brainiacs,

I know [[ Now.getDayOfWeek() ]] gets me “Friday”, for example.
But how do I make my jibberish work: [[ ( 03/01/2018 ).getDayOfWeek()]]?
(I want to get the dayOfWeek from a date.)

I’d like to make a lightweight datepicker that relies on the user’s PC’s calendar “engine”, rather than build one in axure. (I’ve scanned thru the datepicker posts on this forum, and they all seem to build their own calendar engine, incorporating leap years and all.)

I think if i can have 12 conditionals, one for each month, that looks for:

  • the first day-of-week of the month,
  • the number of days in that month,
    … then I can populate the calendar grid reliably.

here’s how I see it working for now:

Hi!

The date functions in Axure are super helpful. Leap years are handled automatically. I’ve made a couple of calendars.

The attached RP file should be enough to get you started. Be sure to check out all of the date functions, which you can find in the dialog that comes up when you hit that fx icon:

Live sample

File: date-math-tips.rp (54.2 KB)

[Edit] I swear, no matter how much I test, I always run into a bug AFTER I post. Change the expression for the number of days in a month to the expression below; otherwise, December breaks:

[[ (curMonth+“/1/”+curYear).addMonths(1).addDays(-1).getDate()]]

(I updated the live sample.)

Hi Joseph,
Much appreciated, your RP file got me past the first few hurdles.

Now that I know:

  • Which dayOfWeek any given month starts with
  • The last day of any given month

Now I need to figure out a lightweight way of numbering the month’s days-grid.

The only way I know how is to give each day, in the month’s first week, an onMove trigger that numbers the rest of the month. I have to specify all the date-numbering.

There’s got to be a smarter way, right?

Here’s what I’ve set up for Sunday in the first week of any given month:

Much appreciated!

Hi!

One of the cleverer solutions (not mine) I’ve seen had a 7-state dynamic panel, all with 31 days, but state 1 starts the month on Sunday, 2 on Monday, etc. So you just choose the appropriate state depending on which day of the week the month starts on, and then adjust it for the appropriate days per month. Crazy fast!

My solution involved a repeater wrapped into a 7x6 grid, but it was also fast because there’s no reading from or writing to the dataset. I just use Item.index to figure out which calendar square I’m drawing, The dataset contained the rows matching the maximum number “squares” a calendar can contain (including blank dates from the previous month) so I’d have that number of squares at my disposal, and to cap it I set itemsPerPage of the repeater. (I wasn’t previewing days from the next month.)