Monday, February 4, 2013

EnScript - DateClass

DateClass gives functions about date and time.
So it's useful when i configure time like GMT.


Let's start DateClass!


NameListClass void NameListClass (NameListClass parent, const String &Name="", uint Options=0)
DayOfWeek int const DayOfWeek ()
Month int const Month ()
Day int const Day ()
Year int const Year ()
GetUnix uint const GetUnix ()
GetDateFormat String static GetDateFormat ()
GetTimeFormat String static GetTimeFormat ()
GetString String const GetString (const String &dateformat, const String &timeformat, int timezonebias)



- NameListClass -
parent - The parent folder for this node
Name - Name
Options - 32-bit unsigned integer

- DayofWeek -
Day of the week (0...6), Sunday = 0

- Month -
Month value (1..12)

- Day -
Day value (1..31)

- Year -
Year value in 4 digit format (1970..2040)

- GetUnix -
Retrieves the date as the number of seconds since 1970

- GetString -
Converts the date to the specified string format
Arguments:
dateformat - MM/dd/yy
timeformat - hh:mm:sstt
timezonebias - Time zone bias in seconds

- GetDateFormat -
Returns the global date format string

- GetTo,eFormat -
Returns the global time format string



I brought it from EnCase Help page.
###########################  Code and Result  ###########################

Black : Code

Red : Result

######################################################################


class MainClass;


class MainClass {


  void Main(CaseClass c) {
    DateClass date();    
    date.Now();
    NameListClass days();
                      days.Parse("Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday", ",");
    NameListClass months();
    months.Parse("Jan,Feb,Mar,April,May,June,July,Aug,Sep,Oct,Nov,Dec", ",");
    Console.WriteLine("Today's date is " + days.ChildName(date.DayOfWeek()) + " " + months.ChildName(date.Month() - 1) + " " + date.Day() + ", " + date.Year());

Today's date is Monday Feb 4, 2013


    Console.WriteLine("number of seconds since 1/1/1970 12:00AM = " + date.GetUnix());

number of seconds since 1/1/1970 12:00AM = 1359945233


    //The GetString(String, String int) method subtracts the bias from GMT
    Console.WriteLine("Current Time In Los Angeles:" + date.GetString(DateClass::GetDateFormat(), DateClass::GetTimeFormat(), 8 * 3600));

Current Time In Los Angeles:02/03/13 06:33:53오후


    Console.WriteLine("Current Time In New York:" + date.GetString(DateClass::GetDateFormat(), DateClass::GetTimeFormat(), 5 * 3600));

Current Time In New York:02/03/13 09:33:53오후


    Console.WriteLine("Current Time In Moscow:" + date.GetString(DateClass::GetDateFormat(), DateClass::GetTimeFormat(), -3 * 3600));

Current Time In Moscow:02/04/13 05:33:53오전


    Console.WriteLine("Current Time In Beijing:" + date.GetString(DateClass::GetDateFormat(), DateClass::GetTimeFormat(), -8 * 3600));

Current Time In Beijing:02/04/13 10:33:53오전


    Console.WriteLine("Note that the above times are not adjusted for Daylight Savings Time and thus may be off by an hour.");

Note that the above times are not adjusted for Daylight Savings Time and thus may be off by an hour.


    Console.WriteLine("Current System Time:" + date.GetString());

Current System Time:02/04/13 11:33:53오전



  }
}




No comments:

Post a Comment