Coverage for gws-app/gws/plugin/model_value/current_timestamp/__init__.py: 0%

10 statements  

« prev     ^ index     » next       coverage.py v7.16.2, created at 2026-10-05 13:35 +0200

1"""Current timestamp value. 

2 

3Computes the current date and time (``gws.lib.datetimex.now``). Typically used 

4to record when a feature was created or changed, or as a bound of a date range 

5validator. 

6 

7Example:: 

8 

9 fields+ { 

10 name "updated_at" 

11 type "datetime" 

12 values+ { type "currentTimestamp" forRead false } 

13 } 

14""" 

15 

16import gws 

17import gws.base.model.value 

18import gws.lib.datetimex 

19 

20 

21@gws.ext.config.modelValue('currentTimestamp') 

22class Config(gws.base.model.value.Config): 

23 """Value set to the current date and time.""" 

24 

25 pass 

26 

27 

28@gws.ext.object.modelValue('currentTimestamp') 

29class Object(gws.base.model.value.Object): 

30 """Current timestamp value object.""" 

31 

32 def compute(self, field, feature, mc): 

33 return gws.lib.datetimex.now()