On Wednesday, January 12, 2011 07:29:39 Mandeep Singh Brar wrote: > Hi, > > Is there a way to parse a Time string like 15:45 to a Date structure. > Parse method in std.date returns it as invalid. As a hack it works by > prepending it with something like 1-1-1970. But is there a cleaner > way to it.
That wouldn't really make sense. It's holds a _date_ and time, not just a time. And just glancing at the implementation, it doesn't look like it can do it. The new std.datetime would allow you to parse it as a time into a std.datetime.TimeOfDay, but that just made it into svn, so it won't be out until the next release (unless you grab the svn version and build it yourself). std.date is pretty buggy overall, so you need to be careful when using it anyway. std.datetime will be replacing it, and it's has _way_ more functionality, and, while likely not bug-free, works much better. But it's only in svn at the moment. So, for the moment, I'd advise either parsing the whole date and time with std.date - even if it's only the time that you want - or just parsing it yourself, which is pretty easy, much as you shouldn't have to. - Jonathan M Davis