0

I'm doing a Web .Net application, on MVC. I create a controller:

 [HttpPost]
    public JsonResult Fechas() {

        DateTime fecha = DateTime.Now;

        List<listas.Ffechas> actualFecha = new List<listas.Ffechas>();

        actualFecha.Add(new listas.Ffechas( fecha.Year.ToString(),
            fecha.Month.ToString(),
            fecha.Hour.ToString(),
            fecha.Minute.ToString(),
            fecha.Second.ToString(),
            fecha.Millisecond.ToString()               

            ));
        return Json(new { actualFecha, JsonRequestBehavior.DenyGet });
    }

This controller its based on a List Model:

  public class Ffechas {
        public string FYear { get; set; }
        public string FMonth { get; set; }

        public string FHour { get; set; }
        public string FMinute { get; set; }
        public string FSecond {get;set;}
        public string FMiliseconds {get;set;}

        public Ffechas(string CYear,string CMonth,  string CHour, string CMinute, string CSecond, string CMiliseconds) {

            FYear = CYear;
            FMonth = CMonth;
            FHour = CHour;
            FMinute = CMinute;
            FSecond = CSecond;
            FMiliseconds = CMiliseconds;
         }
     }

And send the information in Json format. The point here is, How I can detect the actual culture or region language of the system and apply to my fecha Datetime, example:

if the actual system culture is ("en-us") the date is sended on that format or if the actual system culture is ("es-mx") the date is sended on that form.

I dont have problems with list or something like that, my issue is detect the culture system status and with this I can send through json the correct format. thanks for your help.

iviryxavyer
  • 131
  • 1
  • 2
  • 11
  • See: [What is setting CultureInfo.CurrentCulture](https://stackoverflow.com/q/21315761/580951)? – Dustin Kingen Aug 04 '17 at 16:43
  • 1
    Why would the client care what the *server* culture is? Ideally, you should send back the JSON in a machine-readable culture-neutral way, but if you *do* need to localize, I'd expect you to localize to the client's culture, not the server's. – Jon Skeet Aug 04 '17 at 16:44
  • Why create a custom type `Ffechas` with date time members? Just use `System.DateTime` directly, ie. send that as is. It should be transmitted in `ISO8601` format which is culture agnostic. – Igor Aug 04 '17 at 16:45
  • 1
    (As an aside, I'd strongly recommend that you start adopting .NET naming conventions, removing the `F` and `C` prefixes...) – Jon Skeet Aug 04 '17 at 16:45
  • OMG that was fast. thanks. – iviryxavyer Aug 04 '17 at 16:45
  • This system it will be MultiLanguage. And it will be seen in accord to this rule. – iviryxavyer Aug 04 '17 at 16:48

0 Answers0