deprecate SCViewHolder-layRight
[supercollider.git] / SCClassLibrary / Common / Math / Date.sc
blobf6e55a60cd0ef401bb2fbec47bfa1026ca0a912f
1 Date {
2         var <>year=2000, <>month=1, <>day=1, <>hour=0, <>minute=0, <>second=0, <>dayOfWeek=6,
3                 <>rawSeconds=0, <>bootSeconds=0;
5         *getDate { ^this.localtime }
6         *localtime { ^this.new.localtime }
7         *gmtime { ^this.new.gmtime }
8         *new { arg year, month, day, hour, minute, second, dayOfWeek, rawSeconds, bootSeconds;
9                 ^super.newCopyArgs(year, month, day, hour, minute, second, dayOfWeek,
10                                 rawSeconds, bootSeconds);
11         }
12         storeArgs {
13                 ^[year, month, day, hour, minute, second, dayOfWeek, rawSeconds, bootSeconds]
14         }
15         localtime {
16                 _LocalTime
17                 ^this.primitiveFailed
18         }
19         gmtime {
20                 _GMTime
21                 ^this.primitiveFailed
22         }
23         *seed {
24                 // return a value suitable for seeding a random number generator.
25                 _TimeSeed
26         }
28         // strings for time stamping things like filenames.
29         dayStamp {
30                 var s;
31                 s = (((year % 100) * 100 + month) * 100 + day
32                                 + 1000000).asString;
33                 s.removeAt(0); // get rid of the leading '1' char that was put there to force leading zeroes.
34                 ^s
35         }
36         secStamp {
37                 var s;
38                 s = ((hour * 100 + minute) * 100 + second + 1000000).asString;
39                 s.removeAt(0); // get rid of the leading '1' char that was put there to force leading zeroes.
40                 ^s
41         }
42         stamp {
43                 ^this.dayStamp ++ "_" ++ this.secStamp
44         }
45         hourStamp {
46                 ^hour.asString ++ ":" ++ minute ++ ":"  ++ (rawSeconds % 60).round(0.0001)
47         }
48         asSortableString {  // standard database format, alphabetically sortable
49                 ^String.streamContents({ arg s;
50                         s << year;
51                         if(month < 10,{ s <<  0 });
52                         s <<  month;
53                         if(day < 10,{ s <<  0 });
54                         s <<  day;
55                         if(hour < 10,{ s <<  0 });
56                         s <<  hour;
57                         if(minute < 10, { s <<  0 });
58                         s <<  minute;
59                         if(second < 10, { s <<  0 });
60                         s <<  second;
61                 })
62         }
64         asctime {
65                 _AscTime
66                 ^this.primitiveFailed
67         }
68         asString {
69                 ^this.asctime
70         }
71         format {
72                 arg format;
73                 _prStrFTime;
74                 ^this.primitiveFailed
75         }