Results 1 to 6 of 6

Thread: Question Database of Country, Code, Dial Code, Date & Time

  1. #1

    Thread Starter
    ^:^...ANGEL...^:^ wrack's Avatar
    Join Date
    Mar 2002
    Location
    Melbourne, AUSTRALIA
    Posts
    2,695

    Question Question Database of Country, Code, Dial Code, Date & Time

    Hi,

    Working on an app where I need to have a list of Country (Australia), Country Code (AU), Dial Code (61), Short Date Format, Long Date Format, Short Time Format, Long Time Format.

    Searched high and low and nothing I could find contains a succinct information.

    Is there a global list/database available with above information that I can use? Happy with CSV, JSON, XML or other format that I can convert as needed.

    Cheers

  2. #2
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,109

    Re: Question Database of Country, Code, Dial Code, Date & Time

    The question might get better answers here, and doesn't apply to .NET, so this is a better place for it.
    My usual boring signature: Nothing

  3. #3
    PowerPoster Poppa Mintin's Avatar
    Join Date
    Mar 2009
    Location
    Bottesford, North Lincolnshire, England.
    Posts
    2,500

    Re: Question Database of Country, Code, Dial Code, Date & Time

    Have you looked at THIS one ?

    Poppa
    Along with the sunshine there has to be a little rain sometime.

  4. #4
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Posts
    12,398

    Re: Question Database of Country, Code, Dial Code, Date & Time

    To get the Short Date Format, Long Date Format, Short Time Format, and Long Time Format patterns, you can use a .NET program to loop over every culture, get the DateTimeFormat of the currently iterated culture, and then the respective pattern of the currently iterated DateTimeFormat.

    https://docs.microsoft.com/en-us/dot...fo.getcultures is how you would get every culture.
    https://docs.microsoft.com/en-us/dot...next-statement is how you would setup the loop to loop over every culture.
    https://docs.microsoft.com/en-us/dot...datetimeformat is how you would get the DateTimeFormat of the currently iterated culture.

    Here's an example:
    Code:
    Imports System.Globalization
    
    Module Module1
    
        Sub Main()
            For Each cultureInformation In CultureInfo.GetCultures(CultureTypes.AllCultures)
                Dim format As DateTimeFormatInfo = cultureInformation.DateTimeFormat
    
                Console.WriteLine("Culture: {0}", cultureInformation.Name)
                Console.WriteLine("{0}Long Date Format: {1}", ControlChars.Tab, format.LongDatePattern)
                Console.WriteLine("{0}Short Date Format: {1}", ControlChars.Tab, format.ShortDatePattern)
                Console.WriteLine("{0}Long Time Format: {1}", ControlChars.Tab, format.LongTimePattern)
                Console.WriteLine("{0}Short Time Format: {1}", ControlChars.Tab, format.ShortTimePattern)
            Next
    
            Console.ReadLine()
        End Sub
    
    End Module
    Fiddle: https://dotnetfiddle.net/UDQ7E7

    This example uses cultures, but you could pretty easily map a culture to a country.
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | HtmlLessons | CssLessons | Code Tags | Sword of Fury - Jameram

  5. #5

    Thread Starter
    ^:^...ANGEL...^:^ wrack's Avatar
    Join Date
    Mar 2002
    Location
    Melbourne, AUSTRALIA
    Posts
    2,695

    Re: Question Database of Country, Code, Dial Code, Date & Time

    Quote Originally Posted by Poppa Mintin View Post
    Have you looked at THIS one ?

    Poppa
    Thanks. I did but I also wanted a standard date time formats that go along for each country. Turns out that it is not tied to the country but rather the region and the language so more work is needed from my part.

  6. #6

    Thread Starter
    ^:^...ANGEL...^:^ wrack's Avatar
    Join Date
    Mar 2002
    Location
    Melbourne, AUSTRALIA
    Posts
    2,695

    Re: Question Database of Country, Code, Dial Code, Date & Time

    Quote Originally Posted by dday9 View Post
    To get the Short Date Format, Long Date Format, Short Time Format, and Long Time Format patterns, you can use a .NET program to loop over every culture, get the DateTimeFormat of the currently iterated culture, and then the respective pattern of the currently iterated DateTimeFormat.

    https://docs.microsoft.com/en-us/dot...fo.getcultures is how you would get every culture.
    https://docs.microsoft.com/en-us/dot...next-statement is how you would setup the loop to loop over every culture.
    https://docs.microsoft.com/en-us/dot...datetimeformat is how you would get the DateTimeFormat of the currently iterated culture.

    Here's an example:
    Code:
    Imports System.Globalization
    
    Module Module1
    
        Sub Main()
            For Each cultureInformation In CultureInfo.GetCultures(CultureTypes.AllCultures)
                Dim format As DateTimeFormatInfo = cultureInformation.DateTimeFormat
    
                Console.WriteLine("Culture: {0}", cultureInformation.Name)
                Console.WriteLine("{0}Long Date Format: {1}", ControlChars.Tab, format.LongDatePattern)
                Console.WriteLine("{0}Short Date Format: {1}", ControlChars.Tab, format.ShortDatePattern)
                Console.WriteLine("{0}Long Time Format: {1}", ControlChars.Tab, format.LongTimePattern)
                Console.WriteLine("{0}Short Time Format: {1}", ControlChars.Tab, format.ShortTimePattern)
            Next
    
            Console.ReadLine()
        End Sub
    
    End Module
    Fiddle: https://dotnetfiddle.net/UDQ7E7

    This example uses cultures, but you could pretty easily map a culture to a country.
    Thanks. I was originally using that but hoping that there will be a standard date time formats that go along for each country. Turns out that it is not tied to the country but rather the region and the language so more work is needed from my part.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width