coding: convert dat...
 

  You don't need to be an 'investor' to invest in Singletrack: 6 days left: 95% of target - Find out more

[Closed] coding: convert date and time to words

8 Posts
5 Users
0 Reactions
54 Views
Posts: 1
Free Member
Topic starter
 

Anyone? (c# or vb) My Google fu is weak today.


 
Posted : 03/07/2015 7:08 pm
 nbt
Posts: 12381
Full Member
 

Date time d = date time.now
String s = d.toshortdatestring()

I think. No google was involved in the making of this post


 
Posted : 03/07/2015 7:10 pm
Posts: 1
Free Member
Topic starter
 

No, I mean actual words e.g 31/05/2015 would be may thirty first twenty fifteen.

Have just found some suggestions to hard code an array of lookup words, seeing as there aren't that many


 
Posted : 03/07/2015 7:15 pm
 gary
Posts: 534
Full Member
 

Various built in format options for DateTime.ToString(format), or you can roll your own.

All here : https://msdn.microsoft.com/en-us/library/zdtaw1bw%28v=vs.110%29.aspx

Links at the bottom of the page for more info on format strings.

(Edit, but not read closely enough to see if it will do all words as in your example)


 
Posted : 03/07/2015 7:24 pm
Posts: 1
Free Member
Topic starter
 

I familiar with that, there is nothing for converting the day (number, not day of the week).

This is for a recorded phone message.

I've been asked for a 'phonetic' date. It could be that, eg 'May 31 2015 at 5pm' works.


 
Posted : 03/07/2015 7:36 pm
Posts: 0
Free Member
 

Bit of a strange one, be easy to write a method for breaking the DateTime up into bits then using something like http://stackoverflow.com/questions/2729752/converting-numbers-in-to-words-c-sharp to convert the bits there's not a string format method for.


 
Posted : 03/07/2015 7:43 pm
 gary
Posts: 534
Full Member
 

If you're just going to hand it off to some kind of text->speech engine then yes, you would rather hope it would have its own support for numbers.

But if not then yes, you will probably have to roll your own as above


 
Posted : 03/07/2015 7:54 pm
Posts: 3284
Full Member
 

This better not be another help me with my coursework because I have not paid attention thread

First I'm surprised that a text 2 speech thing won't know to say 'thirty first' rather than 'three one'

Anyway, easiest way is probably a whole load of switch statements for each date time component you want to output


 
Posted : 03/07/2015 8:05 pm
Posts: 1
Free Member
Topic starter
 

It's not coursework, just incompletely explained requirements for a rush job. It pretty much just says 'write phonetic date here'. I'm gonna assume I just need to use the word for the month for now. No doubt I'll be wrong!


 
Posted : 03/07/2015 8:27 pm

6 DAYS LEFT
We are currently at 95% of our target!