0

I am implementing a project using the OSA-CBM 3.3 standard. Within that standard, there includes a type called Osacbmtime. I am attempting to parse a DateTime value from type Osacbmtime. Casting doesn't seem to get the job done. Is there a useful (or obvious) approach I can take to accomplish this?

  • add DateTime tag on your question, and you'll get Skeet here like a call to batman – payo Apr 12 '12 at 21:12
  • 1
    @payo: Was already looking :) – Jon Skeet Apr 12 '12 at 21:12
  • 1
    possible duplicate of [How to make class in C#, that can be cast to DateTime?](http://stackoverflow.com/questions/10121630/how-to-make-class-in-c-that-can-be-cast-to-datetime) – BrokenGlass Apr 12 '12 at 21:12
  • I'd rather not register and subscribe just to get hold of an SDK or API documentation - is there any *public* documentation around this? What members does `Osacbmtime` expose? – Jon Skeet Apr 12 '12 at 21:13

2 Answers2

1

Osacbmtime must be a custom library, because Google searches for it yield nothing.

Your best bet, with what little information you have provided about the Osacbmtime type, is to see if it is possible to output it in a date/time format, then parse it into a DateTime object, i.e.

DateTime myDT = DateTime.Parse(myOSACBMTime.ToString("MM/DD/YYYY HH:MM:SS AA"));

Obviously this is pseudocode since I don't have the documentation for Osacbmtime, but (hopefully) you get the general idea.

qJake
  • 16,821
  • 17
  • 83
  • 135
1

Given this snippet from some Java code (virtual the only reference I could find):

DMPort d = new DMPort();
d.lastUpdate = new OsacbmTime();
d.lastUpdate.time = "2007-08-15T16:23:09";
d.lastUpdate.time_type = OsacbmTimeType.OSACBM_TIME_MIMOSA;

I suspect you want something like:

DateTime date = DateTime.ParseExact(time.Time, "s",
                                    CultureInfo.InvariantCulture,
                                    DateTimeStyles.AssumeLocal);

Where s is the format specifier for the sortable 8601 format.

Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194