Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Long date to Short
#10
This function should do what you need . C# function to convert long date string to short date instructions and example how to use in function help comments

Function LongDateToShortDateCslocaleSpecific
Code:
Copy      Help
;/
function ~&results ~date  ~pattern ~CultureCode 

;converts longdate string to shortdate string in c#

;REMARKS
;can be easily converted for other languages
;just change CulturCode  "el-GR" in calling function to language needed 
;and adjust the datepattern string "dddd, d MMMM yyyy" as well.
;see example below.
;to match the culture  date string your trying  convert
;for culture codes and date formats see
;http://www.basicdatepicker.com/samples/cultureinfo.aspx
;
;EXAMPLE
;for greek longdate to shortdate
;out
;str longdate = "Κυριακή, 25 Μαρτίου 2018"
;str result
;str datepattern = "dddd, d MMMM yyyy"
;str locale = "el-GR"
;LongDateToShortDateCslocaleSpecific(result longdate datepattern locale)
;out result

str code=
;using System;
;using System.Globalization;
;public class Example
;{
;,,public static string StaticFunc(string date, string pattern, string culturecode)
;,,{
;,,,;CultureInfo provider = String.IsNullOrEmpty(culturecode)
;;,,,,;? CultureInfo.InvariantCulture // Or use other default
;;,,,,;: new CultureInfo(culturecode);
;,,,string res = DateTime.ParseExact(date, pattern, provider).ToShortDateString();
;,,,return res;
;,,}
;}
str R=CsFunc(code date pattern CultureCode)
results = R
ret


Messages In This Thread
Long date to Short - by ssimop - 03-08-2018, 11:51 AM
RE: Long date to Short - by Gintaras - 03-08-2018, 12:06 PM
RE: Long date to Short - by Gintaras - 03-08-2018, 12:09 PM
RE: Long date to Short - by Kevin - 03-20-2018, 06:56 PM
RE: Long date to Short - by ssimop - 03-20-2018, 07:57 PM
RE: Long date to Short - by Kevin - 03-22-2018, 04:48 AM
RE: Long date to Short - by ssimop - 03-23-2018, 01:21 AM
RE: Long date to Short - by Kevin - 03-23-2018, 03:37 AM
RE: Long date to Short - by Kevin - 03-23-2018, 06:16 AM
RE: Long date to Short - by Kevin - 03-26-2018, 06:53 AM
RE: Long date to Short - by ssimop - 03-26-2018, 07:15 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)