1

How to get the Last Visit Date of a user in remote api?

Topic: How to get the Last Visit Date of a user in remote api?

How to get the Last Visit Date of a user in remote api?

Thanks
J Prabhu
2

How to get the Last Visit Date of a user in remote api?

Re: How to get the Last Visit Date of a user in remote api?

prabhu.janakiraman, just set (or add to) flags 256 value (0x100 - other properties).
You'll get property "ld" (last login date) for each user in seconds (UTC).

Head of Wialon Local Department
Gurtam
3

How to get the Last Visit Date of a user in remote api?

(edited by prabhu.janakiraman 07/12/2016 16:19:22)

Re: How to get the Last Visit Date of a user in remote api?

I have taken the last visit date it is a long value 1481116010. is there any ways to format it to a normal date ?

Thanks
J Prabhu
4

How to get the Last Visit Date of a user in remote api?

Re: How to get the Last Visit Date of a user in remote api?

prabhu.janakiraman, You can create Date object with this value in JS. And then format it like You want.

var time = 1481116010 * 1000;
var d = new Date(time);

But You sholud take into account that it will be formatted using Your PC timezone.
If You want to format in custom timezone - You should remove from this time Your PC's timezone seconds and add custom timezone seconds before formatting.

Head of Wialon Local Department
Gurtam
5

How to get the Last Visit Date of a user in remote api?

Re: How to get the Last Visit Date of a user in remote api?

How to get the time zone value of a user

Thanks
J Prabhu
6

How to get the Last Visit Date of a user in remote api?

(edited by deal 13/12/2016 15:20:38)

Re: How to get the Last Visit Date of a user in remote api?

prabhu.janakiraman, user's timezone and daylight saving time is stored in users custom_property "tz".
You can get it in response json after login:

{
    "host": "...",
    "eid": "",
    "au": "...",
    "tm": 1481630460,
    "wsdk_version": "1.105",
    "user": {
        "nm": "...",
        "cls": 1,
        "id": ...,
        "prp":{"tz": "134228528"}, // here is user's timezone
        ...
    },
    "classes": {...},
    "features": {...}
}
Head of Wialon Local Department
Gurtam
7

How to get the Last Visit Date of a user in remote api?

Re: How to get the Last Visit Date of a user in remote api?

Hi My user's timezone in user settings is (+5:30) value is 19800. But when i took the tz value in remote api "core/use_auth_hash" i get the tz value as 134237528. Why is that? Am i missing something?

Thanks
J Prabhu
8

How to get the Last Visit Date of a user in remote api?

Re: How to get the Last Visit Date of a user in remote api?

prabhu.janakiraman
Check this https://sdk.wialon.com/wiki/en/kit/remo … me/example

9

How to get the Last Visit Date of a user in remote api?

Re: How to get the Last Visit Date of a user in remote api?

Hi I have refer to that link.  and when i tried to do the timezone conversion to my dates i am doing like the below. But the calculation is getting varied for different timezones. can you please specify a common logic or javascript method where i can pass my input and timezone value and get my converted output.

//For -28800    Pacific Time (US & Canada)    -08:00, I need to do the below calculation to get the result
var tz = (-134180992 & 0xffff) | 0xffff0000;
var ld = 1479391853;
console.log(new Date(((ld - (-new Date().getTimezoneOffset() * 60)) + tz)* 1000));


//For 19800    Chennai, Kolkata, Mumbai, New Delhi    +05:30, I need to do the below calculation to get the result
var tz = (134237528 & 0xffff) ;
var ld = 1481631941;
console.log(new Date(((ld - (-new Date().getTimezoneOffset() * 60)) + tz)* 1000));
Thanks
J Prabhu
10

How to get the Last Visit Date of a user in remote api?

(edited by deal 15/12/2016 13:00:55)

Re: How to get the Last Visit Date of a user in remote api?

prabhu.janakiraman, to get user's timezone offset value in seconds just call this function:

wialon.util.DateTime.getTimezoneOffset()

If You need to take into account user's timezone and also user's daylight saving time You can use this function to format time:

var format = "yyyy-MM-dd HH:mm:ss"; // optional
var short = 0; // time or date and time
wialon.util.DateTime.formatTime(<UTC seconds>, short, format);
Head of Wialon Local Department
Gurtam
11

How to get the Last Visit Date of a user in remote api?

Re: How to get the Last Visit Date of a user in remote api?

thanks deal

Thanks
J Prabhu
12

How to get the Last Visit Date of a user in remote api?

Re: How to get the Last Visit Date of a user in remote api?

Hi, can you please tell how to get daylight saving value? I am getting value of daylight as DST after login, but it is always come as -1 even I changed daylight saving in User settings. Am I missing something?

{
    "host": "...",
    "eid": "",
    "au": "...",
    "tm": 1481630460,
    "wsdk_version": "1.105",
    "user": {
        "nm": "...",
        "cls": 1,
        "id": ...,
        "prp":{"tz": "134228528", "dst":"-1"}, // here I am getting -1 always
        ...
    },
    "classes": {...},
    "features": {...}
}

13

How to get the Last Visit Date of a user in remote api?

Re: How to get the Last Visit Date of a user in remote api?

ramesh, timezone and dst is combined in one property tz. See details and example here https://sdk.wialon.com/wiki/en/sidebar/ … time/start

Head of Wialon Local Department
Gurtam
14

How to get the Last Visit Date of a user in remote api?

Re: How to get the Last Visit Date of a user in remote api?

deal, I am using the following function to getting timezone offset,

export function getTimeZoneoffSet(tz: number): number {
    var TZ_TYPE_MASK = 0x0C000000;
    var TZ_TYPE_WITH_DST = 0x08000000;
    var TZ_OFFSET_MASK = 0xFFFFFFFE;

    if ((tz & TZ_TYPE_MASK) != TZ_TYPE_WITH_DST) return tz & TZ_OFFSET_MASK;
    var val = tz & 0x80000000 ? ((tz & 0xFFFF) | 0xFFFF0000) : (tz & 0xFFFF);
    return val;
}

I have tried this with the time zone of Azores (-1:00),
and if I give daylight saving as none then I am getting timezone value as -134155792,
if I select Brazil daylight saving time then I am getting timezone value as -98242064,
But for the both values I am getting timezone offset value is same -3600.

Is that function logic is correct or do I need to change?

15

How to get the Last Visit Date of a user in remote api?

Re: How to get the Last Visit Date of a user in remote api?

ramesh, this is correct. This function returns only timezone offset value in seconds. But DST offset can only be applyed to certain time. Because winter time differs with summer time.
There is special function in SDK JS to get dst for certain time (getDSTOffset) and to format time according to timezone and dst (formatTime). But Remote API operates with raw unix time. And You should format this time yourself. You can calculate dst value by yourself or using some third party library having user's timezone offset value and dst flag.

Head of Wialon Local Department
Gurtam
16

How to get the Last Visit Date of a user in remote api?

Re: How to get the Last Visit Date of a user in remote api?

deal, I convert this timezone to datetime by following function,

public static DateTime GetCustomerDateTime(long utcDate, string timeZone)
{
   DateTime resultDate = new DateTime();
   long tz = 0;
                    
   tz = Convert.ToInt64(timeZone);
   tz = GetTimeZoneoffSet(tz); // this will return time zone offset using the function which I have shared in previous post
   utcDate = utcDate + tz; //Add the customer timezone seconds 
   utcDate = utcDate * 1000; //Change the value to milliseconds
   resultDate = new DateTime(1970, 1, 1, 0, 0, 0, 0).AddMilliseconds(utcDate);
   return resultDate;
}

I am using timezone Azores (-1:00),
Before enabling the daylight saving time this function returns 2017-02-08 04:57:00,
After enabling daylight saving time as Brazil: from third Sunday in October to third Sunday in February also this is returns same date 2017-02-08 04:57:00,
I check this today, so it will satisfy the Brazil daylight saving time, so our expected date time is 2017-02-08 05:57:00 One hour should be add.
Please let me know if I'm doing anything wrong here.

17

How to get the Last Visit Date of a user in remote api?

Re: How to get the Last Visit Date of a user in remote api?

ramesh, calculation of DST offset is implemented only in Wialon SDK JS. And this calculation is not very simple.
There is no such function in Remote API. You should do it by yourself. We can't provide You with realization of DST calculation function on your programming language.
DST offset is not calculated in Your function (only timezone offset) and thus it is not applied to time. The only solution for now is to use third party library which can give you dst offset value according to user's timezone and dst flag.
We will try to find solution of this problem. But such feature can't be made soon.

Head of Wialon Local Department
Gurtam
18

How to get the Last Visit Date of a user in remote api?

Re: How to get the Last Visit Date of a user in remote api?

Hello,

I am one of developer in Fleetilla(https://fleetilla.com/) product.   Currently I need to send Timezone with day-light-saving details from our admin system to client-system of FleetFACTZ. 

Example Timezone,
1. ET(Eastern Time (US/Canada) with DST and without DST
2. AKT(Alaska Time (US/Canada)) with DST and without DST
3. IST(India Time) without DST

19

How to get the Last Visit Date of a user in remote api?

(edited by saravanan.arumugam 04/06/2019 09:41:36)

Re: How to get the Last Visit Date of a user in remote api?

Hello,

I am one of developer in Fleetilla(https://fleetilla.com/) product.   Currently I need to send Timezone with day-light-saving details from our admin system to client-system of FleetFACTZ. 

Example Timezone,
1. ET(Eastern Time (US/Canada) with DST and without DST
2. AKT(Alaska Time (US/Canada)) with DST and without DST
3. IST(India Time) without DST

Please find all timezone in the attachment, which are used timezone and the attachment contains the sample screen-shots.

We are stored above table timezone-info to our admin system.  Find the below screen-shot for FleetFACTZ system - the User-Setting dialog-window.  We expected which data/info wants to send to FleetFACTZ system for storing and retrieving the timezone with day-light-saving data/info for populate the timezone and day-light values to the “User Setting” dialog-window screen in FleetFACTZ systems. 

Kindly guide me to use to send the timezone with day-light-saving info to FleetFACTZ systems and which custom-property we need to use and sample details.

Regards,
Saravanan A

Post's attachments

Attachment icon Fleetilla - Timezone List.docx 92.04 kb, 265 downloads since 2019-06-04 

20

How to get the Last Visit Date of a user in remote api?

Re: How to get the Last Visit Date of a user in remote api?

Hello saravanan.arumugam ,

Please find here example how to calculate timezone with mask by DST https://sdk.wialon.com/wiki/en/sidebar/ … me/example

Diana Cheley
Wialon Hosting Expert
Gurtam