OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 String MonthInputType::serializeWithMilliseconds(double value) const | 79 String MonthInputType::serializeWithMilliseconds(double value) const |
80 { | 80 { |
81 DateComponents date; | 81 DateComponents date; |
82 if (!date.setMillisecondsSinceEpochForMonth(value)) | 82 if (!date.setMillisecondsSinceEpochForMonth(value)) |
83 return String(); | 83 return String(); |
84 return serializeWithComponents(date); | 84 return serializeWithComponents(date); |
85 } | 85 } |
86 | 86 |
87 Decimal MonthInputType::defaultValueForStepUp() const | 87 Decimal MonthInputType::defaultValueForStepUp() const |
88 { | 88 { |
89 double current = currentTimeMS(); | |
90 double utcOffset = calculateUTCOffset(); | |
91 double dstOffset = calculateDSTOffset(current, utcOffset); | |
92 int offset = static_cast<int>((utcOffset + dstOffset) / msPerMinute); | |
93 current += offset * msPerMinute; | |
94 | |
95 DateComponents date; | 89 DateComponents date; |
96 date.setMillisecondsSinceEpochForMonth(current); | 90 date.setMillisecondsSinceEpochForMonth(convertToLocalTime(currentTimeMS())); |
97 double months = date.monthsSinceEpoch(); | 91 double months = date.monthsSinceEpoch(); |
98 ASSERT(std::isfinite(months)); | 92 ASSERT(std::isfinite(months)); |
99 return Decimal::fromDouble(months); | 93 return Decimal::fromDouble(months); |
100 } | 94 } |
101 | 95 |
102 StepRange MonthInputType::createStepRange(AnyStepHandling anyStepHandling) const | 96 StepRange MonthInputType::createStepRange(AnyStepHandling anyStepHandling) const |
103 { | 97 { |
104 DEFINE_STATIC_LOCAL(const StepRange::StepDescription, stepDescription, (mont
hDefaultStep, monthDefaultStepBase, monthStepScaleFactor, StepRange::ParsedStepV
alueShouldBeInteger)); | 98 DEFINE_STATIC_LOCAL(const StepRange::StepDescription, stepDescription, (mont
hDefaultStep, monthDefaultStepBase, monthStepScaleFactor, StepRange::ParsedStepV
alueShouldBeInteger)); |
105 | 99 |
106 return InputType::createStepRange(anyStepHandling, Decimal::fromDouble(month
DefaultStepBase), Decimal::fromDouble(DateComponents::minimumMonth()), Decimal::
fromDouble(DateComponents::maximumMonth()), stepDescription); | 100 return InputType::createStepRange(anyStepHandling, Decimal::fromDouble(month
DefaultStepBase), Decimal::fromDouble(DateComponents::minimumMonth()), Decimal::
fromDouble(DateComponents::maximumMonth()), stepDescription); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 layoutParameters.placeholderForMonth = "--"; | 152 layoutParameters.placeholderForMonth = "--"; |
159 layoutParameters.placeholderForYear = "----"; | 153 layoutParameters.placeholderForYear = "----"; |
160 } | 154 } |
161 | 155 |
162 bool MonthInputType::isValidFormat(bool hasYear, bool hasMonth, bool hasWeek, bo
ol hasDay, bool hasAMPM, bool hasHour, bool hasMinute, bool hasSecond) const | 156 bool MonthInputType::isValidFormat(bool hasYear, bool hasMonth, bool hasWeek, bo
ol hasDay, bool hasAMPM, bool hasHour, bool hasMinute, bool hasSecond) const |
163 { | 157 { |
164 return hasYear && hasMonth; | 158 return hasYear && hasMonth; |
165 } | 159 } |
166 #endif | 160 #endif |
167 } // namespace blink | 161 } // namespace blink |
OLD | NEW |