Thread Rating:
  • 442 Vote(s) - 2.86 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Setting a value to DateField by keyboard
09-27-2011, 07:49 PM, (This post was last modified: 09-27-2011, 07:50 PM by alchimiste.)
#3
RE: Setting a value to DateField by keyboard
Thanks a lot..

I implement what users want with your help.

The modified code as below:
PHP Code:
{DateField
    value 
= {DateTime.date},
    
parse-spec={proc {value:String, require-four-digit-year?:bool, df:DateField }:(date:DateTime, day-start-pos:int, day-end-pos:int, month-start-pos:int, month-end-pos:int, year-start-pos:int, year-end-pos:int)
                   
def buf = {StringBuf value}
                   {if {
buf.find-string "/"} > -1 or {buf.find-string "-"} > -1 then
                       
{if buf.size != 10 then
                           
{return {DateTime}, 8, 9, 5, 6, 0, 3}
                       }
                       
def str = {buf.to-String}
                       
def d = {DateTime year={{str.substr 0, 4}.to-int}, month={{str.substr 5, 2}.to-int}, day={{str.substr 8, 2}.to-int}}
                       {return 
d, 8, 9, 5, 6, 0, 3}
                       
                    else
                       {if 
buf.size != 8 then
                           
{return {DateTime}, 6, 7, 4, 6, 0, 3}
                       }
                       
def str = {buf.to-String}
                       
def d = {DateTime year={{str.substr 0, 4}.to-int}, month={{str.substr 4, 2}.to-int}, day={{str.substr 6, 2}.to-int}}
                       {return 
d, 6, 7, 4, 6, 0, 3}
                   }
               },
    
    
format-spec =
        {
proc {dt:DateTime, df:DateField}:String
            
{return
                
                {
format "%4d%02d%02d", 
                    
dt.info.year, dt.info.month, dt.info.day
                
}
            }
        }
} 


Messages In This Thread
RE: Setting a value to DateField by keyboard - by alchimiste - 09-27-2011, 07:49 PM

Possibly Related Threads...
Thread Author Replies Views Last Post
  DateField の ValueFinished の抑制 umemura 1 2,597 01-24-2013, 08:10 PM
Last Post: umemura
Forum Jump:


Users browsing this thread:
1 Guest(s)

MyBB SQL Error

MyBB has experienced an internal SQL error and cannot continue.

SQL Error:
1017 - Can't find file: 'mybb_threadviews' (errno: 2)
Query:
INSERT INTO mybb_threadviews (tid) VALUES('286')