Ajax Control Toolkit Date Picker - Is it possible to not have to select the day? - ajaxcontroltoolkit

So I can set the date format on the Calendar Extender to it displays just the month, but you would still have to select the Year, then the Month, then the Day.
I would like to just select the Year, then the Month.
<cc2:CalendarExtender ID="DateOfReleaseCalendarExtender" runat="server"
TargetControlID="DateOfReleaseTextBox"
Format="MMMM yyyy" />

That is not a built-in feature, no. You'll have to extend it yourself. I would probably hook into the Javascript events--whichever one you think makes sense in your situation.

This requires patching the CalendarExtender part of the AjaxControlToolkit assembly.
I found a blog post that explains how to do something very similar to what you are trying to do: Patching the CalendarExtender Control

Related

vuetify v-date-picker not start by first day of month in persian locale

Consider the following code
<v-date-picker
v-model="picker"
:first-day-of-week="6"
locale="fa"
></v-date-picker>
<v-date-picker
v-model="picker"
></v-date-picker>
As you can see in the following picture, In Persian calendar month starts by 12th which is the first day of May
Code Output, Left side is Persian calendar
I also have this problem, unfortunately it's an open bug in Vuetify:
[Bug Report] Problem with vuetify Persian datepicker year selection #11578
Which is a duplicate of:
[Bug] Date picker new month is started at the end of previous month in 'FA-local'.
Personally, I had to user vue-persian-datetime-picker. It's pretty good, a simple api and easily customizable. Still, I hope they fix the problem with v-date-picker

Set datepicker for one year from today in Cypress test

I am creating an acceptance test in Cypress that will run regularly, and I need that it enters the date from the datepicker (React, if it is important) as 1 year 1 month and 1 day from the day of creating the object (article). E.g. Today is April 22, 2020, and I want to get May 23, 2021 in the article created today, and tomorrow it would give the value of May 24, 2021 etc. Could anyone share any ideas of setting this up? I honestly googled and I have no ideas myself because I'm quite new to Cypress and feel more or less confident only in pretty straightforward things. :)
I'd guess that most date pickers will have an input element where the date can be typed.
Presuming the app uses a library date picker (so you don't need to test the picking of the date via button clicks), you can target that element and use the Cypress .type() command to enter the future date.
For example, the Material UI date picker docs has this input element
<input aria-invalid="false"
id="date-picker-inline"
type="text"
class="MuiInputBase-input MuiInput-input MuiInputBase-inputAdornedEnd"
value="08/18/2014">
so the steps would be something like
cy.visit('https://material-ui.com/components/pickers');
const targetDate = Cypress.moment()
.add(1, 'year')
.add(1, 'month')
.add(1, 'day')
.format('MM/DD/YYYY') // adjust format to suit the apps requirements
cy.get('input[id="date-picker-inline"]')
.clear()
.type(`${targetDate}{enter}`) // presume you need the enter key to trigger an event
Ref: Cypress.moment
This method was deprecated. You can use this method;
//click the date picker
cy.get('#datepicker').click();
//choose previous month
cy.contains('Prev').click();
//choose next month
cy.contains('Next').click();
//choose date 24
cy.contains('24').click();

Add a class depending on date

I have a standard link that I would like to add a class to depending on a date. Is this possible using Javascript/JQuery?? My code at the moment is simply this:
<div id="box1">1</div>
So if the date is actually 1st July I would like the class to change to "current" and if the date is past 1st July (2nd, 3rd, 4th etc) then the class to be "active".
I'm thinking there maybe a way to do this via Javascript or JQuery or possibly PHP. I'm not a developer so really not too sure. Any help would be appreciated. Thank you in advanced.
Something like this:
Do your date logic
Remove the class: $("#box1 a").removeClass('disabled');
Then add class: $("#box1 a").addClass('active');

reformat date that is pulled from database table

I have a website which uses smarty templates.
I have a table in my db called posts that has various columns, one being "date_added". I managed to have that displayed on the posts by editing one of the Smarty templates for "posts" however, the date format is YYYY-MM-DD.
Is there any easy way for me to change this? Perhaps with jQuery?
Ideally, I want to only show the abbreviated month, with the day positioned next it. This is for a blog style post, but this isn't WordPress.
Right now the smartytemplate the shows the date_added reads like this:
{$posts[i].date_added|stripslashes|nl2br}
Where posts is the table and date_added is a column in that table.
An exact example can be seen here in the top right corner of each post.
http://www.elegantthemes.com/preview/LightBright/
Does anyone have a good suggestion of how I can achieve the desired request?
If you are looking for a javascript solution, you can take a look at the incredible JS Library MomentJS. It is very lightweight and does numerous date and time formats.
http://momentjs.com/
Just include the minified script file in your HTML .
For your exact case, you would use momentJS as such:
First create the momentJS date object:
var moment_date = moment(date_from_database, "YYYY-MM-DD");
Then to display the date as you want:
var date_string = moment_date.format("MMM DD"); // ex. = "Mar 03"
More documentation here: http://momentjs.com/docs/#/displaying/
Then you can use your DOM manipulation library (JQuery for example) to place that string somewhere in your HTML
Good luck
- K

Get date difference in jstl

I have a date and want to show difference of it with current time as --year--month--days--hours--minutes--seconds. How can I do this jstl? It is sure that the date will be greater than current datetime.
Using JSTL you could do some code gymnastics like:
<jsp:useBean id="now" class="java.util.Date" />
<fmt:parseNumber
value="${(now.time - otherDate.time) / (1000*60*60*24) }"
integerOnly="true" /> day(s) passed between given dates.
But as code suggests, this gives overall difference and hardly could be a "calendar aware" way of doing it. I.e. You could not say: "3 years, 1 month and 2 days passed since otherDate".
Another example for this "days passed..." style, using a JSP tag and using "today/yesterday/days back" presentation:
<%--[...]--%>
<%#attribute name="otherDate" required="true" type="java.util.Date"%>
<jsp:useBean id="now" class="java.util.Date" scope="request"/>
<fmt:parseNumber
value="${ now.time / (1000*60*60*24) }"
integerOnly="true" var="nowDays" scope="request"/>
<fmt:parseNumber
value="${ otherDate.time / (1000*60*60*24) }"
integerOnly="true" var="otherDays" scope="page"/>
<c:set value="${nowDays - otherDays}" var="dateDiff"/>
<c:choose>
<c:when test="${dateDiff eq 0}">today</c:when>
<c:when test="${dateDiff eq 1}">yesterday</c:when>
<c:otherwise>${dateDiff} day(s) ago</c:otherwise>
<%--[...]--%>
Note:
In your software problem domain, if it makes sense to talk about days and months in a calendar way, probably you should have that expressed in your Domain Model. If not, at least you should benefit from using another lower software layer to provide this information (and for example using java.util.Calendar or Joda-Time APIs).
Not sure there are any built in ways of doing this with JSTL. you could write your own tag library or potentially use expression language (EL) like below.
${(dateObj) - (now.time)}
taken from Looking for JSTL Taglib calculate seconds between two dates
Mark I'm uncertain if this is possible using JSTL and one way would be to create your own custom tag to handle this as #olly_uk suggested. Me personally would not use any expression language on my JSP as this might also affect readability and not best practise.
You could also have this calculation/date difference when your page bean is constructed, that way avoiding any EL or a new tag. This also might have its limitations such as I'm not sure if the date you want to check the difference is entered by the user on field where you want to display the result instantly etc if you see what I mean.
Also another you could try depending on your scenario is using jQuery to calculate and display the difference, I thought I'll link this page anyway from SO.
How do I get the number of days between two dates in JavaScript?
JQuery Calculate Day Difference in 2 date textboxes
Hope this helps.