0

ワークフロー フォームで日付入力のカスタム バリデーターを開発していますが、日付を解析した後に null が返されます。

// check dates can be parsed        
    str_expiryDate = field.form.prop_wfbxTestWorkFlow_NfDate.value;
    console.log("Non conformite"+str_expiryDate);

    str_reminderDate = field.form.prop_bpm_workflowDueDate.value;
     console.log("echeance"+str_reminderDate);

    Alfresco.logger.warn("Expiry Date: " + str_expiryDate + " | Reminder Date: " + str_reminderDate);

    d_expiryDate = Date.parse(str_expiryDate);
    console.log("nfDate"+str_expiryDate);

    d_reminderDate = Date.parse(str_reminderDate);
    console.log("Date echéance"+d_reminderDate);

そして、コンソールでこれを取得します:

Non conformite2013-06-21T00:00:00.000+01:00 echeance2013-06-09T00:00:00.000+01:00

nfDatenull 日付 echéancenull

これら 2 つの日付を解析して比較するにはどうすればよいですか? 。ありがとう

4

2 に答える 2

1

Alfresco.util.fromISO8601(date)を使用

client-api ドキュメントによると

ISO8601 日付文字列を JavaScript ネイティブ Date オブジェクトに変換します

于 2013-06-05T13:35:17.237 に答える
0

日付自体ではなく、日付の「値」を解析しています。比較する最良の方法は、YYYYMMDD の形式を使用して、それを数値として比較することです。このようなもの(それを行うためのはるかにエレガントな方法は確かにありますが、現時点ではそれが唯一の方法です):

var indexDate=str_expiryDate.indexOf("-");
var dayDate=str_expiryDate.substring(0, 2);
var monthDate=str_expiryDate.substring(3, 5);
var yearDate=fromData.substring(6, str_expiryDate.length+1);
int dataNew=yearDate+monthDate+dayDate;                 

そして、2 つの日付値を比較します。明らかに、インデックス値が正しいかどうかを確認してください。私はそれらを再確認しませんでした。お役に立てば幸いです。

于 2013-06-04T21:12:25.330 に答える