How to expose GetDayOfWeek() to blueprints?

I have exposed functions to blueprints before but I definitely somewhat of a novice C++ programmer. GetDayOfWeek returns data type EDayOfWeek. I just get the below when I try to return that type

From the compiler(xcode):

Unrecognized type ‘EDayOfWeek’ - type
must be a UCLASS, USTRUCT or UENUM

Then if try to return it as an uint8 or something else I get errors saying that I can’t use that type. Can anyone else expose this to blueprint?

https://forums.unrealengine.com/development-discussion/c-gameplay-programming/64217-exposing-datetime-s-getdayofweek-to-blueprints-how-can-i-return-an-edayofweek

Here is the code I’m trying at the moment and isn’t working.

.cpp

EDayOfWeek UDateTimeFunctions::GetDayOfWeek(FDateTime dTime)
{
return dTime->GetDayOfWeek();
}

.hp

UFUNCTION( BlueprintPure, meta = (DisplayName = "Get Weekday", Keywords = "Calendar, Day, Weekday, Date, Time"), Category = Custom )
static EDayOfWeek GetDayOfWeek( FDateTime dTime );

Here is a previous link to a forum where the issue was discussed but there was no concrete resolution, or at least, i wasn’t sure on how the problem is solved.

Many Thanks

how about something like this?

.h

264612-header.png

.cpp (add: #include "Misc/DateTime.h")

264614-implementation.png

Ah brilliant. I will try that out when I get home. Looks like it doesn’t use that EDayOfWeek Enum thus avoiding the problem, which I hadn’t considered doing. Thanks so much for your help. Will mark as answer as soon as I test it out.

Getting this unfortunately…am I doing something super dumb?

ah of course! Thanks so much for your help :slight_smile:

Doesn’t GetDay return the current day of the month though, not the day of the week?

well that will give me an int between 1 to 31 right(depending on the month)? not 0 to 6

yeah, GetDayOfWeek() returns EDayOfWeek, GetDay() returns an int32 :slight_smile:

Also, #include "Misc/DateTime.h"

Internally it gets year/month/day, and returns day.

I get your point. let me check.

edit: btw, today it thinks is tuesday, which is right. so i guess it’s value is like day%7 or something. if it was returning an 8 it would print nope.

You were correct =P, just do this then.

264667-0.png

That works. Thank you! It really helps when learning C++ when you have people to show you the way now and again. Thanks again.