how to add current date as start date while generating a mpp file using java? - ms-project

I am working on a small project where we need to generate a MPP plan from reference plan. In my reference mpp file i have some old date. When we are generating the new plan we are expecting the start date of the project should be current date. I tried by exploring the available methos of Calander( MPXJ project file calander). My requirement is to set the Task's start date as curent date. But there are no methods available to set the tesks startdate. Will be helpful if i get quick response. Thanks in advance.

java.util.Date now = new java.util.Date();
String today = new java.sql.Date(now.getTime())+"";
/*
* if you want it in date format then
* java.util.Date today = new java.sql.Date(now.getTime());
*/

Currently MPXJ doesn't support writing to an MPP File. You may consider using Aspose Tasks to write something to an MPP file.
Remember, it's not free.

Related

Cypress.moment using locale

I am trying to use Cypress.moment to compare dates. The targeted website is in french so the date format.
Therefore, I intended to use moment.js method to switch fr locale.
Cypress.moment.locale('fr')
I should be able to do that as they say on cypress documentation :
Cypress automatically includes moment.js and exposes it as Cypress.moment
https://docs.cypress.io/api/utilities/moment.html#Syntax
Then,
const todaysDate = Cypress.moment().format('Do')
const currentMonth = Cypress.moment().format('MMMM')
cy.get('.date__title').should('contain', todaysDate)
cy.get('.c-title').should('contain', currentMonth)
But the assertion fails as cypress refuse to take into account the fr locale. It keeps comparing 'décembre' with 'december' for instance. Which fails obviously.
I am doing something wrong ?
in the same aforementioned thread, a working answer recently surfaced:
put this in support/index.js:
Cypress.moment.locale('de');
it worked brilliantly in my project
Unfortunately, at the time of writing, I think this is not possible with Cypress.moment.locale(), as you can see in this issue in their git repository.
As commented there moment.locale requires an import in addition to the standard moment import, that import is moment-with-locales.min.js and has not been included in Cypress.

How do I add an Apps Script Library to AppMaker?

I created this script to determine if the Session.getScriptTimeZone() would draw the time zone from the library file rather than AppMaker. Here's the script:
function getFormattedDateString(dt,format){
var format=format||"E MMM dd, yyyy HH:mm";
var dt=dt||new Date();
return Utilities.formatDate(new Date(dt), Session.getScriptTimeZone(), format);
}
I tested it in another script with the following code:
function test(){
Logger.log(AMSLib.getFormattedDateString(new Date()));
}
I went into AppMaker and this dialog:
I've tried the Script ID from here:
I've also tried several deployment ID's from the publish from Manifest dialog and I keep getting the same answer:
I've also tried the Project Key which is used with other apps scripts to load libraries.
I don't know what to try next.
First things first, you need to publish your Apps Script app, after that it'll be assigned Script ID(by the way it can also be found in the published app URL). Once you have Script ID, you can specify it in App Maker and select library version you want to use:
To access library's functions you need to use name specified in the object setting:
// Server side library call
var result = MyLibraryName.doSomeCoolStuff();
App Maker should be smart enough and pickup all library's public functions for autocomplete.
Learn more:
https://developers.google.com/apps-script/guides/libraries
https://developers.google.com/appmaker/scripting/libraries
That's really odd to not have a script key there. You might make a copy of your script, something might be corrupted. You can also get the key from the URL ex: https://script.google.com/a/ignitesynergy.com/d/1oHnk_xl76KagGS4g7O2pC1MM4R3iZR8-7FlmzKXxRDtO1o5nDU2/edit
Remember to File-> Manage Versions and create a version. You also need to set the sharing to public.

How to properly output DateTime with TYPO3 extbase fluid

I got two dateTime Objects stored in the Database:
2014-11-03 09:00:00
2014-10-21 13:45:00
When i try to output them with the ViewHelper format.date
<f:format.date format="H:i">{termin.datumBeginn}</f:format.date>
I get the following results:
10:00
15:45
So i got a one hour shift and a two hour shift which i can't write a workaround for. How do i set the timezones properly to have a clean output?
Although this is very old, I want to highlight that this was a bug in Extbase until recently, and we fixed it in TYPO3 7.6 and 8. The dates are now properly read as UTC, as which they are stored in the database, and converted to your server timezone.
Ensure that all dates in you database are in same timezone, because that information is not saved there. When you receive some objects from external API calls, they will have timezone in date string and it will be usually UTC. From your internal calls all \DateTime objects will use by default your server default timezone. So set timezone before saving it to database:
$receivedDate = new \DateTime($date);
$reveivedDate->setTimezone(new \DateTimeZone(date_default_timezone_get()));
Setting timezone to server default is convenient, because requires no more changes.. but it's better to save it in 'UTC' I think. In that case you will need to convert it back to your server/user timezone before showing it. It can be done in ViewHelper (not default one from Typo3.Fluid but you can easily extend it in your package - clone and set timezone again). Maybe it's possible now to use doctrine extensions in flow, and save timezone with date to database.. i tried it year ago and couldn't make it..
To solve this issue you need to set $TYPO3_CONF_VARS['SYS']['phpTimeZone'] as "UTC" and $TYPO3_CONF_VARS['SYS']['serverTimeZone'] as "0" (probably only first setting will be enough). You can do it through typo3 backend, using Install tool.
If you have domain model you can use a workaround:
/**
* Returns the startDate
*
* #return \DateTime|NULL $startDate
*/
public function getStartDate() {
$date = $this->startDate;
if($date) {
$date->setTimezone(new \DateTimeZone('UTC'));
}
return $date;
}
Please make sure that you have put setting the Timezone for PHP in the php.ini file
Example: date.timezone = "Asia/Phnom_Penh"
For more information of PHP Timezone please refer to this link: http://php.net/manual/en/timezones.america.php

How to get the correct LastModifiedDate from SPFile in SP2013

I've got a Issue with SharePoint 2013 Files in Libraries. If I push an File via WebDAV into an Folder the file will still hold it's created/modified date (and that's good!).
Other Case is: I use the "New Document" Upload Form - the File will be newly created and loses its correct created/modified date.
I'm looking for a way to get these correct Values of the SPFile Item.
DateTime modified = Li.File.TimeLastModified;
That's my current attempt to get the DateTime but it only retrieves the "sharepoint" value and not the "filesystem" value of the LastModifiedDate.
I tried to let my Webpart open the File on the server.. but URI-Formats arent supported :-(
Has anybody already run into this problem?
Thanks for your help in advance!
EDIT:
This is what I get in explorer view of the document library. For example the file lync.PNG has a last modified date of 26.12.2013.
this is what I get from my webpart using the code snippet (sorry for the german description; "geändert am" means lastmodifieddate)
You can get the modified date that SharePoint uses by getting the Item of the SPFile then reading the date property. Something like this:
DateTime date = DateTime.Parse(file.Item["Modified"].ToString());
Once its in SharePoint any changes should come from the modified property of the item. You would have to use an event receiver to capture the original file date and then overwrite the SharePoint created date, or add the value to another field in the item.
Hope this helps.

Custom date format (callback with php logic)

I want to create a dynamic php date format. Example: show the time of the node if it was published today and only the day/month when older then today. I want this format to be available throughout Drupal like the other predefined date formats in Drupal (not just on theme level).
I found the (D7 only) hook for hook_date_format_types but even that one doesn't seem to allow for a callback where I could define this PHP logic.
Does anyone know which hook would make this possible? Or a module which does this?
In Drupal6, format_date() has the dates and times hardcoded. Also, format_date() does not allow callbacks, but it does allow a custom string. That is where you can apply a trick: instead of hardcoding the string in there, you call a function that returns a string.
function mydate_format($timestamp) {
$now = time();
if (($now - $timestamp) < (60*60*24)) {
return "H:i";
}
else {
return "d:m:Y";
}
}
print format_date($timestamp, 'custom', mydate_format($timestamp));
The second option is to re-define a date-timestamp, but that is both hackish and limited. Date-formats are defined with variable_get(), but don't pass the timestamp along; so your example of switching formats based on the value of timestamp is not possible this way.
In settings.php:
$conf['date_format_long'] = $conf['debug'] ? 'r' : 'l, F j, Y - H:i';
This will switch from one value to another, based on whether your settings.php has a flag "debug" set to TRUE or not. As mentioned: the use for this is limited, since you cannot get any context.
The third alternative is to use Date API which offers onlinle configurable time-formats. But that is both clumsy and insecure (inputting executable PHP in your database). It also depends on a very large module-set. And has the same downside as the first solution: you cannot use format_date, but must use a modified function call, instead of format_date(). See all the options at The Drupal.org date themeing handbook.
GOTCHA In all cases Drupal will not call this function for cached content. If you want to have the dates really dynamic you either need to avoid caching alltogether, or implement the date-formatting in clientside javascript.
TL;DR: You cannot have dynamic date-formats without changing some of the code on theme-level. Using a callback-function to generate the "custom" dateformat is the simplest, working solution.
You can use Date API module to add your custom date formatting. Date API module is inside the Date module. After enabling the Date API module you can go the path "admin/settings/date-time/formats/add" to add your custom format.
"admin/settings/date-time/formats/configure" is the path to configure date formats.
Have a look at these. Happy coding.
Thanks
RT
You can go to node.tpl.php(possibly in sites/all/themes/theme_name/node.tpl.php). Here yo can find $created variable, to reformat date you can use your custom function and change the $created as you want.After this all nodes will use your formatted dates.
Regatds,
Chintan.
Use the features module. Create a feature.
In the resulting feature module, on the [feature].module file, create a hook_nodeapi function and format the field with a conditional statement that takes into account the current date() for how the date will be displayed and feed it into the $node->content var.
And that is the way rockstars would do it (-;

Resources