I make a simple domain class
class Meetings {
Date when
String where
}
Then I run 'generate-all' on Meetings. I then start the app 'RunApp'.
In the app I'm able to to choose the month, day, and year for the when variable, however I can't choose the time as in hours:minutes (example 7:30). I wouldn't expect to be able to do this, but if I save the date it formats it as month, day, year, and then -00:00:00. How do I set the time using the date variable? or is there another way?
If you are using the datepicker tag in grails, it is pretty straight forward.
In the views folder under a domain class folder there is _form.gsp. Inside _form.gsp is a date picker tag.
<g:datePicker name="dateTimeVariableName" value="${dateTimeValue}"
default="${new Date().clearTime()}" precision="minute"/>
The keyword here is precision.
You should check the documentation. Its always a good idea. Hope this helps.
Related
In the "Activity for jobs' page in Rundeck the execution time has a relative time field (example: "Today at 10:15 AM" or "Last Sunday at 4:51 AM") after the timestamp.
It is easy to change the date format of the timestamp by adding jobslist...format[.ko] in the i18n/messages.properties file.
It seems impossible however to change the format of the relative time message. It seems to be hard-coded in en_US with AM/PM which doesn't look too good in in non-English-speaking countries. The format is always the same regardless of the ?lang=xx parameter or the default language in the browser. Interestingly, other objects (like hovering over the field with the mouse and the duration get translated).
Has anyone successfully changed this?
Example. See the duration field
I have been trying this with the docker images (4.8.0, 4.9.0 and SNAPSHOT)
I've looked at the source code and apparently this lies somewhere in the moment.js code.
In some parts, the date formats are hard coded as you say, please add your use case on this thread.
I am trying to compare and check the date if it is today's date or not in a spesific program. I tried to use assertion method but when I use it the time will remain same if you try it next day. The main problem that I need to know when open a page from program It should be today's date and should be passed. if you know already anything about it please let me know also :)
Thanks yo!
Use System.DateTime.Now.ToString("yyyy-MM-dd") as one argument of the assertion. You may need to use a different format rather in the ...ToString() method. The exact format depends on how the date is shown on the screen.
This could be done using "StringAssert" to verify that your programs date string contains today's date string, while ignoring the time:
var programDateString = "7/25/2016 12:00:00"; //this is an example of your date retrieved from the application with time included
var todaysDate = System.DateTime.Today.ToShortDateString(); //short date string
StringAssert.Contains(programDateString, todaysDate);
This has been giving me trouble for a long time now, and I wouldn't think this would be so hard. I have a model with some dates, and date data coming from the API like so:
{
...
tollgate1: '2016-04-15',
tollgate2: '2017-01-01',
projectClose: '2016-10-21',
}
I created a format-date helper (which uses moment.js) to format the dates in view mode, like so:
And that's shows it correctly. However, when I switch to edit mode, the input elements are still referencing the same values, but now they all go one day earlier!
This has been maddening for some time. I've thought it might be due to a like of time zone information in the data, but since I can't change the data that's fed to my app, how can I get it to just display the date in the data, regardless of timezone? For example, with the Tollgate 1 date, I would want it to show April 15 no matter where the user is in the world.
Okay, so as with many things, this isn't an Ember thing so much as just a JavaScript thing. It's really hard learning both at once!
Since my dates coming down from the API don't have a time zone, they're assumed to be GMT, and so my EST timezone of -4 hours makes it show as the day before. Apparently moment.js has some built-in handling so that's why the format-date helper works fine.
What I did to solve is to just add computed properties on my model for each date, and create a new Date object by pulling out the parts from the input date, like so:
function convertDateToUtc(d) {
if(d) {
return new Date(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate());
} else {
return null;
}
}
export default DS.Model.extend({
...
tollgate1Date: Ember.computed('tollgate1', function() {
return convertDateToUtc(this.get('tollgate1'));
})
});
With DateJS, you'd add e.g. six months to the current date like this:
Date.today().addMonths(6);
However, I need to add 24 months not to today's date, but to a date which a user has typed into a date field. So the today() should in principle be replaced by something like this.getField('begin_date').value.
The result shall be written into another data form field.
I tried hard, but couldn't make it. Can anyone help me out?
Providing the input value is a textual representation of a date, you need to convert it into a Date object at the first place. Then you can work with it as you want.
DateJS has a pretty smart parse() function which does exactly that, so you'd achieve it like this:
Date.parse(this.getField('begin_date').value).addMonths(24)
When a specific date format is needed, like DD.MM.YYYY commonly used in Europe, you can use parseExact() and specify the format. Like this:
Date.parseExact(dateToParse, 'dd.MM.yyyy') // leading zeroes required; parses 01.04.2014 but not 1.4.2014
Date.parseExact(dateToParse, 'd.M.yyyy') // leading zeroes not required; parses both 01.04.2014 and 1.4.2014
Here is a solution that I found for my problem, using DateJS as well:
start = this.getField('begin_date').value;
var d1 = util.scand("dd.mm.yyyy", start);
var myDate = new Date(d1);
result = myDate.addMonths(24);
This works pretty fine, also spanning leap years, except for the 28th of February, 2014/2018/2022 ... ; the result then will be the 28th of February, 2016/2020/2024 ... and not the 29th of February 2016/2020/2024... In these cases it's up to the user to accept the 28th or to manually change the date to the 29th.
On Facebook, each comment or other user event has a timestamp. But it is not listed as a simple date, but presented in a form of a human-friendly string. For example if right now it is 08:38 and the comment was made at 08:31, Facebook doesn't just tell you the time, but says "7 minutes ago".
Is there an open source implementation of Facebook algorithm (or similar) that takes a data of event, a current date and tells in a human-friendly form how long has it been since?
Pretty date http://ejohn.org/projects/javascript-pretty-date/ is a good javascript library for this
You could dig into timeago jQuery plugin's source code to study.
What I think that should be the best is this :
Store the timestamp when the comment is made (eg- 3:45 12-10-2012)
Get the current system time
Get the differnce between the two .i.e (current time -comment time ) .
Most of the languages provide the datediff method . Like in PHP you can use it like this