Closed shaulbehr closed 7 years ago
I apologize i didn't see this until now. Looking into it.
First off. 'toUniversalTime()' is a method that you are referencing like a delegate with no proper this reference.
Try this instead:
let today = DateTime.today;
let vacationDates = Enumerable.from(vacations)
.select(v => {
return {
utcStartDate: v.startDate.toUniversalTime(),
utcEndDate: v.endDate.toUniversalTime(),
localStartDate: v.startDate,
todayUtc: today.toUniversalTime()
};
});
let first = vacationDates.first();
Lemme know if this is solved.
Hi,
I was taken off this project for a while; now I'm back.
I just updated to TypeScript.NET 4.9.5 and tried what you suggested, i.e. adding ()
to .toUniversalTime
. Doesn't compile:
Cannot invoke an expression whose type lacks a call signature. Type 'DateTime' has no compatible call signatures.)
Hello again. :) As before, I can't really be sure what's wrong without your latest code sample.
let vacationDates = Enumerable.from(vacations)
.select(v => {
return {startDate: v.startDate.toUniversalTime, endDate: v.endDate.toUniversalTime};
});
where vacations
is of type Vacation[]
:
import {DateTime} from "typescript-dotnet-amd/System/Time/DateTime";
export class Vacation {
public vacationId: string;
public schoolId: string;
public vacationDescription: string;
public startDate: DateTime;
public endDate: DateTime;
}
Ok I see the issue now. This is a mistake on my part.
.toUniversalTime
is some how an accessor and it shouldn't be.
But you will need to call it like this after I fix: v.startDate.toUniversalTime()
https://github.com/electricessence/TypeScript.NET/commit/2f6ae36a058769bdf203032a53c0b25d8d33a680
So you'll need to change the use to treat it like a method.
This is how the DateTime
class in .NET is.
With the sample code you provided, I'm still uncertain why the compiler would give you grief. Please update to 4.9.6 and try the changes I suggested and let me know if it fixes it.
Here's my code:
In normal online mode, this behaves as expected. But in offline mode,
first.utcStartDate
andfirst.utcEndDate
haveundefined
value.first.localStartDate
andfirst.todayUtc
have the correct values. (Vacation.startDate
andVacation.endDate
areDateTime
values.)