Rally Software

 View Only
  • 1.  Lookback API vs WSAPI - Date comparison

    Posted Jan 21, 2020 06:08 PM
    Hello,

    For a given feature, I try to compare a date attribute (planned start date and planned end date) between now (WSAPI) and yesterday (Lookback API). Just to clear any doubt: the date values did not change in the meanwhile, I expect to have the same values :)

    Here is what I get with the LookBack API:
    planned start date = 2018-10-22T00:00:00.000Z
    planned end date = 2019-03-22T23:59:59.000Z ​
    Here is what I get with the WSAPI:
    planned start date = Mon Oct 22 2018 13:00:00 GMT+0200 (Central European Summer Time)
    planned end date = Sat Mar 23 2019 11:59:59 GMT+0100 (Central European Standard Time)
    In order to compare the dates, I try to have the same type of object and date format. I convert the ISO format from Lookback API to the Rally format using Rally.util.DateTime.fromIsoString(myFeature.PlannedStartDate) and here is what I get:
    planned start date = Mon Oct 22 2018 02:00:00 GMT+0200 (Central European Summer Time)
    planned end date = Sat Mar 23 2019 00:59:59 GMT+0100 (Central European Standard Time)

    In the end, my dates are not comparable: the year/month/day/minutes/seconds/timezone are matching but not the hours.

    Have I missed something in Lookback API dates management?

    Thanks for your inputs,
    Greg.



  • 2.  RE: Lookback API vs WSAPI - Date comparison
    Best Answer

    Broadcom Employee
    Posted Jan 22, 2020 04:02 AM
    Hi Greg,

    Can you have a look at what timezone your workspace is set to? You can either ask your subadmin to tell you, or alternatively, it comes up in the Portfolio Items view if you have the Planned End Date shown, e.g:


    The reason for asking is that the WSAPI gives me a time with the offset included. For example, I have a workspace set to 'Denver' time and from the UK, it gives me F1 as finishing at 2020-01-30 11:59 PM MST in the UI, but 2020-01-31 06:59:59 in WSAPI.

    The 13 hours different makes me think you are in a workspace set to Alaska time even though you are in Finland, Latvia or somewhere in Eastern Europe.

    ------------------------------
    Nik
    Ask me a question, I'm All Ears!
    Rally Sales Engineer
    Rally Software
    ------------------------------



  • 3.  RE: Lookback API vs WSAPI - Date comparison

    Posted Jan 22, 2020 09:21 AM
    Hi Nik!

    Thanks for your help!

    I confirm what you suppose: the workspace seems to be configured on Samoa timezone whereas I'm on Paris timezone:

    I'll check if I can convert both dates to the same timezones.

    Thanks Nik :)



  • 4.  RE: Lookback API vs WSAPI - Date comparison

    Posted Jan 23, 2020 05:41 PM
    In case in can help someone else, here is how I managed to convert yesterday date (2020-01-22 at 23h59) to the Samoa timezone date. Then I convert it to ISO string format so that it can be used with LookbackAPI queries.
    // Yesterday date on local timezone
    var lookbackApiDate = new Date(2020, 00, 22, 23, 59, 59);
    
    // Date converted to UTC+14 (Samoa timezone), like dates returned by my Rally workspace, compatible with WSAPI
    var lookbackApiDateWithSSTTimezone = convertDateToOffset(dateToLoad, 14);
    
    // Date converted to ISO format, compatible with LookbackAPI queries
    var isoStringDateOnSSTTimezone = Rally.util.DateTime.toIsoString(lookbackApiDateWithSSTTimezone );

    The method uses the Luxon library to easily manage the timezone change:

    		// offset is the number of hours (positive or negative) from UTC
    		// SST is +14
    		// Uses the LUXON library
    		function convertDateToOffset(theDate, offset) {
    			var utc = 'UTC'+(offset >= 0 ? '+'+offset.toString() : '-'+offset.toString());
    			var dt = luxon.DateTime.fromJSDate(theDate).setZone(utc);
    			var dtz = new Date(dt.year, dt.month-1, dt.day, dt.hour, dt.minute, dt.second);
    			return dtz;
    		}



  • 5.  RE: Lookback API vs WSAPI - Date comparison

    Posted Jan 23, 2020 05:49 PM
    Edited by Gregory Garcia Jan 23, 2020 05:52 PM
    So, I tried to retrieve my "UTC" timezone setting from my Rally project using the Javascript SDK2 WSAPI:
    function loadWorkspace() {
    	Ext.create('Rally.data.WsapiDataStore', {
    		model: 'Workspace',
    		context: {
    			workspace: gvRallyWorkspace,
    			project: gvRallyProject,
    			projectScopeUp: false,
    			projectScopeDown: false
    		},
    		autoLoad: true,
    		listeners: {
    			scope: this,
    			load: function (store, records, successful) {
    				if (successful) {
    					loadedWorkspace(store, records);
    				} else {
    					console.log('There was a problem finding values for workspaces.');
    				}
    			}
    		}
    	});
    }
    
    function loadedWorkspace(store, wksp) {
    		console.log(wksp);
    }
    The query works well and I get the attributes of the workspace set in query context... But I can see nothing in the workspace object that defines the UTC timezone offset. The Notes attributes seems to hold some configuration but no timezone settings:

    Does someone know how to retrieve the Rally workspace UTC offset value from SDK2?