datetime-format

Complement [FromUri] serialization with APIController

做~自己de王妃 提交于 2019-12-05 18:09:08
We have multiple API controllers accepting GET requests like so: //FooController public IHttpActionResult Get([FromUri]Foo f); //BarController public IHttpActionResult Get([FromUri]Bar b); Now - we would like (or, are forced) to change DateTime string format within GET query string globally "yyyy-MM-ddTHH:mm:ss" -> "yyyy-MM-ddTHH.mm.ss" After the change all [FromUri] serializations with classes containing DateTime types fail. Is there a way to complement [FromUri] serialization to accept the DateTime format in query string? Or do we have to build custom serialization for all API parameters to

How to format a datetime with minimal separators and timezone in VBScript?

别等时光非礼了梦想. 提交于 2019-12-05 17:25:37
I have the following code in C#: DateTime dt = GetDateTime(); string formatted = dt.ToString("yyyyMMddTHHmmsszz"); which returns a date in the following format: 20100806T112917+01 I would like to be able to get the same results in VBScript (for a legacy ASP application). It is especially important that I get the UTC offset information, or have the time converted to UTC. How do I do that? For date formatting, I like using the .NET StringBuilder class from VBScript: Option Explicit Dim sb : Set sb = CreateObject("System.Text.StringBuilder") sb.AppendFormat "{0:yyyyMMddTHHmmsszz}", Now() Response

how to deserialize DateTime in Lift

▼魔方 西西 提交于 2019-12-05 15:01:41
I am having trouble deserializing a org.joda.time.DateTime field from JSON into a case class. The JSON: val ajson=parse(""" { "creationDate": "2013-01-02T10:48:41.000-05:00" }""") I also set these serialization options: implicit val formats = Serialization.formats(NoTypeHints) ++ net.liftweb.json.ext.JodaTimeSerializers.all And the deserialization: val val1=ajson.extract[Post] where Post is: case class Post( creationDate : DateTime){ ... } The exception I get is: net.liftweb.json.MappingException: No usable value for creationDate Invalid date format 2013-01-02T10:48:41.000-05:00 How can I

Jest: test Intl.DateTimeFormat

心不动则不痛 提交于 2019-12-05 07:36:23
I would like to test a filter function I wrote which return a date formatted using Intl.DateTimeFormat('en-GB', options): // module "date.js" export default function (dateISOString) { const options = { year: 'numeric', month: '2-digit', day: '2-digit', timeZone: 'UTC' }; let d = new Date(dateISOString); return new Intl.DateTimeFormat('en-GB', options).format(d); }; This is my test, using Jest: import date from '@/filters/date'; describe('date', () => { it('should format the date into dd/mm/yyyy', () => { expect(date('2014-02-11')).toEqual('11/02/2014'); }); }); but it fails with: Expected

`datetime.strftime` and `datetime.strptime` interprete %Y differently

点点圈 提交于 2019-12-05 06:52:10
I use a statement as shown below to create a datetime object from a string: t = datetime.strptime("0023-10-10", "%Y-%m-%d") Later, somewhere in my code uses the t object and invoke the strftime method with the same format string: t.strftime("%Y-%m-%d") This causes a ValueError: year=23 is before 1900; the datetime strftime() methods require year >= 1900 . It seems that the validation of the %Y input is different in this two similar methods. So I have to do the following to make sure I don't accept some bad years like 23 : try: format = "%Y-%m-%d" t = datetime.strptime("0023-10-10", format) t

Convert DateTime from English to Spanish

三世轮回 提交于 2019-12-05 05:39:25
Does anybody know how to convert a DateTime from English to Spanish? E.g convert: Monday, January 01, 2011 into Lunes, Enero 01, 2011 ??? Thanks in advance. Yyou can use CultureInfo to do this, if you set the current culture in the running thread the date will format in the correct culture http://msdn.microsoft.com/en-us/library/5hh873ya.aspx in vb.net Dim TheDate As DateTime = DateTime.Parse("January 01 2011") Thread.CurrentThread.CurrentCulture = New CultureInfo("es-ES") MsgBox(TheDate.ToLongDateString) or c# DateTime TheDate = DateTime.Parse("January 01 2011"); Thread.CurrentThread

how to achieve timespan to string conversion?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-05 02:08:30
I tried searching here , but it couldn't help me much .. I want to convert time_span to string, I don't want to return the timespan in days .. but only HH:mm:ss. How to achieve that? My sample code is here: String time_span_par = "06:12:40"; String time_str = "18:13:59"; TimeSpan time_span_var = TimeSpan.Parse(time_span_par); TimeSpan time_span = TimeSpan.Parse(time_str); time_span = time_span.Add(time_span_var); string temp = time_span.ToString("HH:mm:ss"); Try using DateTime d = new DateTime(time_span.Ticks); string time = d.ToString("HH:mm:ss"); Kelsey This should work: string temp = string

Representing Fraction of Second with ISO 8601:2004

老子叫甜甜 提交于 2019-12-05 01:48:57
问题 The following is the definition of IS0 8601:2004 standard. It says that the fraction of second can be represented with one to six digits. Can I use all the 6 digits for representing the fraction of a second? Are the following Representation correct, if I use 6 digits for representing fraction of a second? 1ms -- 001000 10ms -- 010000 100ms -- 100000 {Extended Time Format} (32 bytes) YYYY-MM-DDThh:mm:ss.sTZD YYYY = Year 0000 to 9999 MM = Month 01 to 12 DD = Day 01 to 31 T = special separator T

How to set format of current date time to different format?

北战南征 提交于 2019-12-04 21:31:12
I use the following code to retrieve the current date and time, then add it to table using following method. Change 2013-07-29 23:20:34.0 to 29th July 2013, 11:20 PM DateTime public Date getCurrentDateTime() { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date date = new Date(); System.out.println("current:" + dateFormat.format(date)); return date; } Hibernate @Temporal(javax.persistence.TemporalType.TIMESTAMP) public Date getCurrentDateTime() { return date; } To change the day to ordinal number you need to use the following suffix . have a look at this link as

how do I parse an iso 8601 date (with optional milliseconds) to a struct tm in C++?

蹲街弑〆低调 提交于 2019-12-04 16:45:20
问题 I have a string which should specify a date and time in ISO 8601 format, which may or may not have milliseconds in it, and I am wanting to get a struct tm from it as well as any millisecond value that may have been specified (which can be assumed to be zero if not present in the string). What would be involved in detecting whether the string is in the correct format, as well as converting a user-specified string into the struct tm and millisecond values? If it weren't for the millisconds