• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mattonem / PharoJS / 14358269857

11 Mar 2025 04:04PM UTC coverage: 42.026% (-17.4%) from 59.444%
14358269857

push

github

mattonem
more catching

1 of 1 new or added line in 1 file covered. (100.0%)

3707 existing lines in 69 files now uncovered.

8909 of 21199 relevant lines covered (42.03%)

0.42 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/Pharo/PharoJs-Base-JS-CoreLibraries/PjTime.class.st
1
"
2
Time in the Javascript world
3
"
4
Class {
5
        #name : 'PjTime',
6
        #superclass : 'Object',
7
        #traits : 'PjTDateAndTime',
8
        #classTraits : 'PjTDateAndTime classTrait',
9
        #pools : [
10
                'ChronologyConstants'
11
        ],
12
        #category : 'PharoJs-Base-JS-CoreLibraries-Chronology',
13
        #package : 'PharoJs-Base-JS-CoreLibraries',
14
        #tag : 'Chronology'
15
}
16

17
{ #category : 'instance creation' }
18
PjTime class >> hour: hour minute: minute second: second milliSecond: milliseconds [
×
19
        <javascript: '
×
20
        var today = new Date();
×
21
        return new Date(today.getFullYear(), today.getMonth(), today.getDate(), hour, minute, second, milliseconds);'>
×
22
]
×
23

24
{ #category : 'instance creation' }
25
PjTime class >> hour: hour minute: minute second: second nanoSecond: nanoCount [
×
26
        ^self hour: hour minute: minute second: second milliSecond: nanoCount // 1000000
×
27
]
×
28

29
{ #category : 'pharoJs support' }
UNCOV
30
PjTime class >> javascriptName [
×
UNCOV
31
        <pharoJsSkip>
×
UNCOV
32
        ^ #Date
×
UNCOV
33
]
×
34

35
{ #category : 'pharoJs support' }
UNCOV
36
PjTime class >> jsTranspilationImportMethods [
×
UNCOV
37
        <pharoJsSkip>
×
UNCOV
38
        | classSelectors instanceSelectors |
×
UNCOV
39
        classSelectors := Time class 
×
UNCOV
40
                selectorsInProtocols: #('instance creation' '*PharoExtra-instance creation' '*Kernel-Chronology-Extras')  
×
UNCOV
41
                exclude: #(now nowLocal fromString: readFrom: seconds:nanoSeconds: seconds:  hour:minute:second:milliSecond: hour:minute:second:nanoSecond:
×
UNCOV
42
                benchmarkMillisecondClock benchmarkPrimitiveResponseDelay dateAndTimeFromSeconds:
×
UNCOV
43
                ). 
×
UNCOV
44
        instanceSelectors := Time 
×
UNCOV
45
                selectorsInProtocols: #(accessing "adding comparing converting")
×
UNCOV
46
                exclude: #(hour12 hour24 minute second).
×
UNCOV
47
        ^{Time class -> classSelectors.
×
UNCOV
48
        Time -> instanceSelectors }
×
UNCOV
49
]
×
50

51
{ #category : 'clock' }
52
PjTime class >> millisecondClockValue [
×
53
        <javascript: 'if(typeof performance=="object") return performance.now();
×
54
if(typeof process=="object"){var hr=process.hrtime();return hr[0]*1000+hr[1]/1000000}
×
55
return Date.now()'>
×
56
]
×
57

58
{ #category : 'instance creation' }
59
PjTime class >> now [
×
60
        <javascript: 'return new this()'>
×
61
]
×
62

63
{ #category : 'instance creation' }
64
PjTime class >> seconds: seconds [
×
65
        ^self seconds: seconds nanoSeconds: 0
×
66
]
×
67

68
{ #category : 'instance creation' }
69
PjTime class >> seconds: seconds nanoSeconds: nanoCount [
×
70
        "Answer a Time from midnight."
×
71
        ^self basicNew
×
72
                seconds: seconds nanoSeconds: nanoCount;
×
73
                yourself
×
74
]
×
75

76
{ #category : 'converting' }
77
PjTime >> asDateAndTime [
×
78
        ^self
×
79
]
×
80

81
{ #category : 'converting' }
82
PjTime >> asSeconds [
×
83
        ^(self hour24 * 3600) + (self minute * 60) + self seconds
×
84
]
×
85

86
{ #category : 'accessing' }
87
PjTime >> dayOfMonth [
×
88
        ^self getDate
×
89
]
×
90

91
{ #category : 'accessing' }
92
PjTime >> dayOfWeek [
×
93
        ^self getDay + 1
×
94
]
×
95

96
{ #category : 'accessing' }
97
PjTime >> hour [
×
98
        ^self hour24
×
99
]
×
100

101
{ #category : 'accessing' }
102
PjTime >> hour12 [
×
103
        | hour24 |
×
104
        hour24 := self hour24.
×
105
        hour24 = 0 ifTrue: [ ^12 ].
×
106
        hour24 > 12 ifTrue: [ ^hour24 - 12 ].
×
107
        ^hour24
×
108
]
×
109

110
{ #category : 'accessing' }
111
PjTime >> hour24 [
×
112
        ^self getHours
×
113
]
×
114

115
{ #category : 'accessing' }
116
PjTime >> milliSecond [
×
117
        ^self getMilliseconds
×
118
]
×
119

120
{ #category : 'accessing' }
121
PjTime >> minute [
×
122
        ^self getMinutes
×
123
]
×
124

125
{ #category : 'accessing' }
126
PjTime >> monthIndex [
×
127
        ^self getMonth + 1
×
128
]
×
129

130
{ #category : 'accessing' }
131
PjTime >> monthIndex: anInteger [
×
132
        ^self month: anInteger - 1
×
133
]
×
134

135
{ #category : 'accessing' }
136
PjTime >> second [
×
137
        ^self getSeconds
×
138
]
×
139

140
{ #category : 'private' }
141
PjTime >> seconds: secondCount [
×
142
        | minuteSecondsCount |
×
143
        self setHours: (secondCount quo: SecondsInHour).
×
144
        minuteSecondsCount := secondCount rem: SecondsInHour.
×
145
        self setMinutes: (minuteSecondsCount quo: SecondsInMinute).
×
146
        self setSeconds: (minuteSecondsCount rem: SecondsInMinute).
×
147
]
×
148

149
{ #category : 'private' }
150
PjTime >> seconds: secondCount nanoSeconds: nanoCount [ 
×
151
        self seconds: secondCount.
×
152
        self setMilliseconds: nanoCount//1000000
×
153
]
×
154

155
{ #category : 'private' }
156
PjTime >> ticks: anArray [
×
157
        "ticks is an Array: { days. seconds. nanoSeconds }"
×
158
        self seconds: (anArray at: 2) nanoSeconds: anArray last
×
159
]
×
160

161
{ #category : 'accessing' }
162
PjTime >> year [
×
163
        ^self getFullYear
×
164
]
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc