No announcement yet.

Native implementation of DateTime class?

  • Filter
  • Time
  • Show
Clear All
new posts

    Native implementation of DateTime class?

    I have had to implement my own class for working with DateTime objects (comparing dates, determining time difference, time epoch/timestamps, etc).

    Is there nothing already available in the native code that I have missed?

    I know UE4 has the FDateTime class:

    But i don't see anything in UnrealScript.

    Are you using this?

    local int Day, DayOfWeek, Month, Year, Hour, Minute, Second, MSecond;
    GetSystemTime(Year, Month, DayOfWeek, Day, Hour, Minute, Second, MSecond);
    Check out Himeko Sutori, the upcoming tactical RPG where you control armies of over 100 unique characters.


      Nathaniel3W Yes I'm aware of this (it's what I'm using in the class i implemented).

      There is no handling for comparing time objects, getting time elapsed, checking days in a given month, leap years, unix epoch timestamps. No way to perform logic operators on a DateTime objects.

      Like saying date1 < date2 for instance.

      Or checking time elapsed from date1.

      Almost all programing languages I've used provide a DateTime class, it's just weird that it's absent from US.

      What I have implemented is mostly fine. There are just a few holes in it (like not accounting for leap-years).


        there are some macros in core folder in global.uci file at the bottom, not sure if these will help you out.

        /** This is a slick way to to do thing like: TimeSince(LastFoo) < Delta where the macro makes it a lot easier to read what the code is doing **/
        `define TimeSince(Time) (WorldInfo.TimeSeconds - `Time)
        /** This is used for classes which are object derived and do not have access to WorldInfo so we need to pass in the Actor to get a worldinfo **/
        `define TimeSinceEx(Actor,Time) (`Actor.WorldInfo.TimeSeconds - `Time)


          Thanks gamepainters. But those are related to game time, not system DateTime.